本文整理汇总了C++中BlockInfo类的典型用法代码示例。如果您正苦于以下问题:C++ BlockInfo类的具体用法?C++ BlockInfo怎么用?C++ BlockInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeLoopsRecursively
void ShortestPathAnalysis::analyzeLoopsRecursively(SILLoop *Loop, int LoopDepth) {
if (LoopDepth >= MaxNumLoopLevels)
return;
// First dive into the inner loops.
for (SILLoop *SubLoop : Loop->getSubLoops()) {
analyzeLoopsRecursively(SubLoop, LoopDepth + 1);
}
BlockInfo *HeaderInfo = getBlockInfo(Loop->getHeader());
Distances &HeaderDists = HeaderInfo->getDistances(LoopDepth);
// Initial values for the entry (== header) and exit-predecessor (== header as
// well).
HeaderDists.DistFromEntry = 0;
HeaderDists.DistToExit = 0;
solveDataFlow(Loop->getBlocks(), LoopDepth);
int LoopLength = getExitDistFromSuccs(Loop->getHeader(), LoopDepth) +
HeaderInfo->getLength(LoopDepth);
HeaderDists.DistToExit = LoopLength;
// If there is a loop bypass edge, add the loop length to the loop pre-pre-
// header instead to the header. This actually let us ignore the loop bypass
// edge in the length calculation for the loop's parent scope.
if (SILBasicBlock *Bypass = detectLoopBypassPreheader(Loop))
HeaderInfo = getBlockInfo(Bypass);
// Add the full loop length (= assumed-iteration-count * length) to the loop
// header so that it is considered in the parent scope.
HeaderInfo->getDistances(LoopDepth - 1).LoopHeaderLength =
LoopCount * LoopLength;
}
示例2: COPY
void MapExtras::Block::ParseBasemats(TileInfo *tiles, BasematInfo *bmats)
{
BlockInfo info;
info.prepare(this);
COPY(bmats->layermat, info.basemats);
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 16; y++)
{
using namespace df::enums::tiletype_material;
auto tt = tiles->base_tiles[x][y];
auto mat = info.getBaseMaterial(tt, df::coord2d(x,y));
bmats->mattype[x][y] = mat.mat_type;
bmats->matindex[x][y] = mat.mat_index;
// Copy base info back to construction layer
if (tiles->con_info && !tiles->con_info->constructed.getassignment(x,y))
{
tiles->con_info->mattype[x][y] = mat.mat_type;
tiles->con_info->matindex[x][y] = mat.mat_index;
}
}
}
}
示例3: getBlockInfo
void ShortestPathAnalysis::printBlockInfo(llvm::raw_ostream &OS,
SILBasicBlock *BB, int LoopDepth) {
BlockInfo *BBInfo = getBlockInfo(BB);
Distances &D = BBInfo->getDistances(LoopDepth);
OS << " bb" << BB->getDebugID() << ": length=" << BBInfo->Length << '+'
<< D.LoopHeaderLength << ", d-entry=" << D.DistFromEntry
<< ", d-exit=" << D.DistToExit << '\n';
}
示例4: catch
bool State::sync(BlockChain const& _bc, h256 _block)
{
bool ret = false;
// BLOCK
BlockInfo bi;
try
{
auto b = _bc.block(_block);
bi.populate(b);
bi.verifyInternals(_bc.block(_block));
}
catch (...)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
exit(1);
}
if (bi == m_currentBlock)
{
// We mined the last block.
// Our state is good - we just need to move on to next.
m_previousBlock = m_currentBlock;
resetCurrent();
m_currentNumber++;
ret = true;
}
else if (bi == m_previousBlock)
{
// No change since last sync.
// Carry on as we were.
}
else
{
// New blocks available, or we've switched to a different branch. All change.
// Find most recent state dump and replay what's left.
// (Most recent state dump might end up being genesis.)
std::vector<h256> chain;
while (bi.stateRoot != BlockInfo::genesis().hash && m_db.lookup(bi.stateRoot).empty()) // while we don't have the state root of the latest block...
{
chain.push_back(bi.hash); // push back for later replay.
bi.populate(_bc.block(bi.parentHash)); // move to parent.
}
m_previousBlock = bi;
resetCurrent();
// Iterate through in reverse, playing back each of the blocks.
for (auto it = chain.rbegin(); it != chain.rend(); ++it)
playback(_bc.block(*it), true);
m_currentNumber = _bc.details(_block).number + 1;
resetCurrent();
ret = true;
}
return ret;
}
示例5: populateFromParent
void BlockInfo::populateFromParent(BlockInfo const& _parent)
{
m_stateRoot = _parent.stateRoot();
m_number = _parent.m_number + 1;
m_parentHash = _parent.m_hash;
m_gasLimit = _parent.childGasLimit();
m_gasUsed = 0;
m_difficulty = calculateDifficulty(_parent);
}
示例6: BlockInfo
//递归地开辟300块
BlockInfo* BlockHandle::Add(BlockInfo* block)
{
//开辟新块,编号都为0
BlockInfo* adder = new BlockInfo(0);
adder->SetNext(block->GetNext());
block->SetNext(adder);
block_count_++;
if (block_count_ == block_size_) return adder;
else return Add(adder);
}
示例7: GetBlockInfo
BlockInfo* FileHandle::GetBlockInfo(FileInfo* file, int block_pos)
{
BlockInfo* bp = file->GetFirstBlock();
while (bp != NULL)
{
if (bp->get_block_num() == block_pos)
return bp;
bp = bp->GetNext();
}
return NULL;
}
示例8: GetUsableBlock
/* 返回可用块的首指针*/
BlockInfo* BlockHandle::GetUsableBlock()
{
if (block_count_ == 0) return NULL;
BlockInfo* p = first_block_->GetNext();
first_block_->SetNext(first_block_->GetNext()->GetNext());
block_count_--;
p->ResetAge();
p->SetNext(NULL);
return p;
}
示例9: while
BlockHandle::~BlockHandle()
{
BlockInfo* b = first_block_;
//释放所有块
while (block_count_ > 0)
{
BlockInfo* bn = b->GetNext();
delete b;
b = bn;
block_count_--;
}
}
示例10: biParent
u256 State::enactOn(bytesConstRef _block, BlockInfo const& _bi, BlockChain const& _bc)
{
// Check family:
BlockInfo biParent(_bc.block(_bi.parentHash));
_bi.verifyParent(biParent);
BlockInfo biGrandParent;
if (biParent.number)
biGrandParent.populate(_bc.block(biParent.parentHash));
sync(_bc, _bi.parentHash);
resetCurrent();
m_previousBlock = biParent;
return enact(_block, _bc);
}
示例11: AddBlockInfo
void FileHandle::AddBlockInfo(BlockInfo* block)
{
BlockInfo *bp = block->GetFile()->GetFirstBlock();
if (bp == NULL) block->GetFile()->SetFirstBlock(block);
else
{
while (bp->GetNext() != NULL)
bp = bp->GetNext();
bp->SetNext(block);
}
block->GetFile()->IncreaseRecordAmount();
block->GetFile()->IncreaseRecordLength();
}
示例12: host
unsigned BlockChainSync::estimatedHashes() const
{
BlockInfo block = host().chain().info();
time_t lastBlockTime = (block.hash() == host().chain().genesisHash()) ? 1428192000 : (time_t)block.timestamp();
time_t now = time(0);
unsigned blockCount = c_chainReorgSize;
if (lastBlockTime > now)
clog(NetWarn) << "Clock skew? Latest block is in the future";
else
blockCount += (now - lastBlockTime) / (unsigned)c_durationLimit;
clog(NetAllDetail) << "Estimated hashes: " << blockCount;
return blockCount;
}
示例13: _is_intersecting
bool _is_intersecting(tBox& box, const BlockInfo& info) const
{
Real min_pos[2], max_pos[2];
info.pos(min_pos, 0,0);
info.pos(max_pos, B::sizeX-1, B::sizeY-1);
const Real intersection[2] = {
min(max_pos[0], (Real)(box.center[0] + box.h[0]*0.5)) - max(min_pos[0], (Real)(box.center[0] - box.h[0]*0.5)),
min(max_pos[1], (Real)(box.center[1] + box.h[1]*0.5)) - max(min_pos[1], (Real)(box.center[1] - box.h[1]*0.5))
};
return intersection[0]>=0 && intersection[1]>=0;
}
示例14: GetUsableBlock
BlockInfo* BufferManager::GetFileBlock(string db_name, string tb_name, int file_type, int block_num)
{
fhandle_->IncreaseAge();
FileInfo *file = fhandle_->GetFileInfo(db_name, tb_name, file_type);
if (file)
{
BlockInfo *blo = fhandle_->GetBlockInfo(file, block_num);
if (blo)
return blo;
else /* new block */
{
BlockInfo *bp = GetUsableBlock();
bp->set_block_num(block_num);
bp->SetFile(file);
bp->ReadInfo(path_);
fhandle_->AddBlockInfo(bp);
return bp;
}
}
else
{
BlockInfo *bp = GetUsableBlock();
bp->set_block_num(block_num);
FileInfo *fp = new FileInfo(db_name,file_type,tb_name, 0 , 0, NULL, NULL);
fhandle_->AddFileInfo(fp);
bp->SetFile(fp);
bp->ReadInfo(path_);
fhandle_->AddBlockInfo(bp);
return bp;
}
return 0;
}
示例15: while
void FileHandle::IncreaseAge()
{
FileInfo* fp = first_file_;
while (fp != NULL)
{
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
bp->IncreaseAge();
bp = bp->GetNext();
}
fp = fp->GetNext();
}
}