MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / LoadChainTip

Method LoadChainTip

src/validation.cpp:5218–5245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5216}
5217
5218bool Chainstate::LoadChainTip() {
5219 AssertLockHeld(cs_main);
5220 const CCoinsViewCache &coins_cache = CoinsTip();
5221 // Never called when the coins view is empty
5222 assert(!coins_cache.GetBestBlock().IsNull());
5223 const CBlockIndex *tip = m_chain.Tip();
5224
5225 if (tip && tip->GetBlockHash() == coins_cache.GetBestBlock()) {
5226 return true;
5227 }
5228
5229 // Load pointer to end of best chain
5230 CBlockIndex *pindex =
5231 m_blockman.LookupBlockIndex(coins_cache.GetBestBlock());
5232 if (!pindex) {
5233 return false;
5234 }
5235 m_chain.SetTip(*pindex);
5236 PruneBlockIndexCandidates();
5237
5238 tip = m_chain.Tip();
5239 LogPrintf(
5240 "Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f\n",
5241 tip->GetBlockHash().ToString(), m_chain.Height(),
5242 FormatISO8601DateTime(tip->GetBlockTime()),
5243 GuessVerificationProgress(m_chainman.GetParams().TxData(), tip));
5244 return true;
5245}
5246
5247CVerifyDB::CVerifyDB(Notifications &notifications)
5248 : m_notifications{notifications} {

Callers 4

validation.cppFile · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.80

Calls 11

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

Tested by 2

BOOST_FIXTURE_TEST_CASEFunction · 0.64