mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Merge #15999: init: Remove dead code in LoadChainTip
fa86c8aec6
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: utACKfa86c8aec6
. practicalswift: utACKfa86c8aec6
Empact: utACKfa86c8aec6
laanwj: utACKfa86c8aec6
ryanofsky: utACKfa86c8aec6
. LoadChainTip isn't called currently when pcoinsTip best block is null due to this line: jamesob: utACKfa86c8aec6
Tree-SHA512: 8961c0e579800a52038ac5655478468852faac055299b64d6cfdf0c213d3bf09669c4889467d09d93457f6c8b073967bb0475a137f77ddd3a3a3c03ad90001c4
This commit is contained in:
commit
a822a0e4f6
1 changed files with 1 additions and 11 deletions
|
@ -3951,20 +3951,10 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_RE
|
|||
bool LoadChainTip(const CChainParams& chainparams)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
assert(!pcoinsTip->GetBestBlock().IsNull()); // Never called when the coins view is empty
|
||||
|
||||
if (::ChainActive().Tip() && ::ChainActive().Tip()->GetBlockHash() == pcoinsTip->GetBestBlock()) return true;
|
||||
|
||||
if (pcoinsTip->GetBestBlock().IsNull() && mapBlockIndex.size() == 1) {
|
||||
// In case we just added the genesis block, connect it now, so
|
||||
// that we always have a ::ChainActive().Tip() when we return.
|
||||
LogPrintf("%s: Connecting genesis block...\n", __func__);
|
||||
CValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams)) {
|
||||
LogPrintf("%s: failed to activate chain (%s)\n", __func__, FormatStateMessage(state));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Load pointer to end of best chain
|
||||
CBlockIndex* pindex = LookupBlockIndex(pcoinsTip->GetBestBlock());
|
||||
if (!pindex) {
|
||||
|
|
Loading…
Add table
Reference in a new issue