MCPcopy Create free account
hub / github.com/ElementsProject/elements / LoadChainTip

Method LoadChainTip

src/validation.cpp:4264–4290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4262}
4263
4264bool CChainState::LoadChainTip()
4265{
4266 AssertLockHeld(cs_main);
4267 const CCoinsViewCache& coins_cache = CoinsTip();
4268 assert(!coins_cache.GetBestBlock().IsNull()); // Never called when the coins view is empty
4269 const CBlockIndex* tip = m_chain.Tip();
4270
4271 if (tip && tip->GetBlockHash() == coins_cache.GetBestBlock()) {
4272 return true;
4273 }
4274
4275 // Load pointer to end of best chain
4276 CBlockIndex* pindex = m_blockman.LookupBlockIndex(coins_cache.GetBestBlock());
4277 if (!pindex) {
4278 return false;
4279 }
4280 m_chain.SetTip(pindex);
4281 PruneBlockIndexCandidates();
4282
4283 tip = m_chain.Tip();
4284 LogPrintf("Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f\n",
4285 tip->GetBlockHash().ToString(),
4286 m_chain.Height(),
4287 FormatISO8601DateTime(tip->GetBlockTime()),
4288 GuessVerificationProgress(tip, m_params.GetConsensus().nPowTargetSpacing));
4289 return true;
4290}
4291
4292CVerifyDB::CVerifyDB()
4293{

Callers 2

ActivateSnapshotMethod · 0.80
LoadChainstateFunction · 0.80

Calls 10

LookupBlockIndexMethod · 0.80
SetTipMethod · 0.80
HeightMethod · 0.80
IsNullMethod · 0.45
GetBestBlockMethod · 0.45
TipMethod · 0.45
GetBlockHashMethod · 0.45
ToStringMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected