Skip to content

Commit a822a0e

Browse files
author
MarcoFalke
committed
Merge #15999: init: Remove dead code in LoadChainTip
fa86c8a init: Remove dead code in LoadChainTip (MarcoFalke) Pull request description: `LoadChainTip` sets `::ChainActive()` based on `pcoinsTip`'s best block. `LoadChainTip` is never called when that block is null, so we can remove all code from within that method that is only executed when that block is null. Fixes #15967 Inconsistent locking behavior in LoadChainTip ACKs for commit fa86c8: promag: utACK fa86c8a. practicalswift: utACK fa86c8a Empact: utACK bitcoin/bitcoin@fa86c8a laanwj: utACK fa86c8a ryanofsky: utACK fa86c8a. LoadChainTip isn't called currently when pcoinsTip best block is null due to this line: jamesob: utACK bitcoin/bitcoin@fa86c8a Tree-SHA512: 8961c0e579800a52038ac5655478468852faac055299b64d6cfdf0c213d3bf09669c4889467d09d93457f6c8b073967bb0475a137f77ddd3a3a3c03ad90001c4
2 parents f3d27d1 + fa86c8a commit a822a0e

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/validation.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,20 +3951,10 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_RE
39513951
bool LoadChainTip(const CChainParams& chainparams)
39523952
{
39533953
AssertLockHeld(cs_main);
3954+
assert(!pcoinsTip->GetBestBlock().IsNull()); // Never called when the coins view is empty
39543955

39553956
if (::ChainActive().Tip() && ::ChainActive().Tip()->GetBlockHash() == pcoinsTip->GetBestBlock()) return true;
39563957

3957-
if (pcoinsTip->GetBestBlock().IsNull() && mapBlockIndex.size() == 1) {
3958-
// In case we just added the genesis block, connect it now, so
3959-
// that we always have a ::ChainActive().Tip() when we return.
3960-
LogPrintf("%s: Connecting genesis block...\n", __func__);
3961-
CValidationState state;
3962-
if (!ActivateBestChain(state, chainparams)) {
3963-
LogPrintf("%s: failed to activate chain (%s)\n", __func__, FormatStateMessage(state));
3964-
return false;
3965-
}
3966-
}
3967-
39683958
// Load pointer to end of best chain
39693959
CBlockIndex* pindex = LookupBlockIndex(pcoinsTip->GetBestBlock());
39703960
if (!pindex) {

0 commit comments

Comments
 (0)