MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / LoadChainTip

Function LoadChainTip

src/validation.cpp:4190–4221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4188}
4189
4190bool LoadChainTip(const CChainParams& chainparams)
4191{
4192 AssertLockHeld(cs_main);
4193
4194 if (chainActive.Tip() && chainActive.Tip()->GetBlockHash() == pcoinsTip->GetBestBlock()) return true;
4195
4196 if (pcoinsTip->GetBestBlock().IsNull() && mapBlockIndex.size() == 1) {
4197 // In case we just added the genesis block, connect it now, so
4198 // that we always have a chainActive.Tip() when we return.
4199 LogPrintf("%s: Connecting genesis block...\n", __func__);
4200 CValidationState state;
4201 if (!ActivateBestChain(state, chainparams)) {
4202 LogPrintf("%s: failed to activate chain (%s)\n", __func__, FormatStateMessage(state));
4203 return false;
4204 }
4205 }
4206
4207 // Load pointer to end of best chain
4208 CBlockIndex* pindex = LookupBlockIndex(pcoinsTip->GetBestBlock());
4209 if (!pindex) {
4210 return false;
4211 }
4212 chainActive.SetTip(pindex);
4213
4214 g_chainstate.PruneBlockIndexCandidates();
4215
4216 LogPrintf("Loaded best chain: hashBestChain=%s height=%d date=%s progress=%f\n",
4217 chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
4218 FormatISO8601DateTime(chainActive.Tip()->GetBlockTime()),
4219 GuessVerificationProgress(chainparams.TxData(), chainActive.Tip()));
4220 return true;
4221}
4222
4223CVerifyDB::CVerifyDB()
4224{

Callers 1

AppInitMainFunction · 0.85

Calls 15

ActivateBestChainFunction · 0.85
FormatStateMessageFunction · 0.85
LookupBlockIndexFunction · 0.85
FormatISO8601DateTimeFunction · 0.85
SetTipMethod · 0.80
HeightMethod · 0.80
TipMethod · 0.45
GetBlockHashMethod · 0.45
GetBestBlockMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected