本文整理汇总了C++中BlockMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockMap::find方法的具体用法?C++ BlockMap::find怎么用?C++ BlockMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockMap
的用法示例。
在下文中一共展示了BlockMap::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findBlockParent
static void findBlockParent(
Block *b
)
{
auto where = lseek64(
b->chunk->getMap()->fd,
b->chunk->getOffset(),
SEEK_SET
);
if(where!=(signed)b->chunk->getOffset()) {
sysErrFatal(
"failed to seek into block chain file %s",
b->chunk->getMap()->name.c_str()
);
}
uint8_t buf[gHeaderSize];
auto nbRead = read(
b->chunk->getMap()->fd,
buf,
gHeaderSize
);
if(nbRead<(signed)gHeaderSize) {
sysErrFatal(
"failed to read from block chain file %s",
b->chunk->getMap()->name.c_str()
);
}
auto i = gBlockMap.find(4 + buf);
if(unlikely(gBlockMap.end()==i)) {
uint8_t bHash[2*kSHA256ByteSize + 1];
toHex(bHash, b->hash);
uint8_t pHash[2*kSHA256ByteSize + 1];
toHex(pHash, 4 + buf);
warning(
"in block %s failed to locate parent block %s",
bHash,
pHash
);
return;
}
b->prev = i->second;
}
示例2: getBlockHeader
static void getBlockHeader(
size_t &size,
Block *&prev,
uint8_t *&hash,
size_t &earlyMissCnt,
const uint8_t *p
) {
LOAD(uint32_t, magic, p);
if(unlikely(gExpectedMagic!=magic)) {
hash = 0;
return;
}
LOAD(uint32_t, sz, p);
size = sz;
prev = 0;
hash = allocHash256();
#if defined(DARKCOIN)
h9(hash, p, gHeaderSize);
#elif defined(PAYCON)
h13(hash, p, gHeaderSize);
#elif defined(MARTEXCOIN)
h13(hash, p, gHeaderSize);
#elif defined(CLAM)
auto pBis = p;
LOAD(uint32_t, nVersion, pBis);
if(6<nVersion) {
sha256Twice(hash, p, gHeaderSize);
} else {
scrypt(hash, p, gHeaderSize);
}
#elif defined(JUMBUCKS)
scrypt(hash, p, gHeaderSize);
#else
sha256Twice(hash, p, gHeaderSize);
#endif
auto i = gBlockMap.find(p + 4);
if(likely(gBlockMap.end()!=i)) {
prev = i->second;
} else {
++earlyMissCnt;
}
}
示例3: linkBlock
static void linkBlock(
Block *block
)
{
if(unlikely(0==block->data)) {
block->height = 0;
block->prev = 0;
block->next = 0;
return;
}
int depth = 0;
Block *b = block;
while(b->height<0) {
auto i = gBlockMap.find(4 + b->data);
if(unlikely(gBlockMap.end()==i)) {
uint8_t buf[2*kSHA256ByteSize + 1];
toHex(buf, 4 + b->data);
warning("at depth %d in chain, failed to locate parent block %s", depth, buf);
return;
}
Block *prev = i->second;
prev->next = b;
b->prev = prev;
b = prev;
++depth;
}
uint64_t h = b->height;
while(block!=b) {
Block *next = b->next;
b->height = h;
b->next = 0;
if(likely(gMaxHeight<h)) {
gMaxHeight = h;
gMaxBlock = b;
}
b = next;
++h;
}
}
示例4: getBlock
IloInt getBlock(IloNumVar x) const {
BlockMap::const_iterator const it = blockMap.find(x);
return (it == blockMap.end()) ? -1 : it->second;
}