diff options
author | Carl Dong <contact@carldong.me> | 2020-09-15 16:06:45 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-01-28 14:15:26 -0500 |
commit | 2a696472a1423e877bfa83f016f66c7e45be7369 (patch) | |
tree | ed4edda50fbdf988293e55c0e15faae505b278e6 | |
parent | 9c300cc8b3ce3d82874982fbf3087e48a6ac0ef2 (diff) |
validation: Pass in chainstate to ::NotifyHeaderTip
[META] This commit should be followed up by removing the comments and
assertions meant only to show that the change is correct.
-rw-r--r-- | src/validation.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index f7aca45e66..16245cae8d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2770,7 +2770,7 @@ static SynchronizationState GetSynchronizationState(bool init) return SynchronizationState::INIT_DOWNLOAD; } -static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { +static bool NotifyHeaderTip(CChainState& chainstate) LOCKS_EXCLUDED(cs_main) { bool fNotify = false; bool fInitialBlockDownload = false; static CBlockIndex* pindexHeaderOld = nullptr; @@ -2781,7 +2781,8 @@ static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { if (pindexHeader != pindexHeaderOld) { fNotify = true; - fInitialBlockDownload = ::ChainstateActive().IsInitialBlockDownload(); + assert(std::addressof(::ChainstateActive()) == std::addressof(chainstate)); + fInitialBlockDownload = chainstate.IsInitialBlockDownload(); pindexHeaderOld = pindexHeader; } } @@ -3664,7 +3665,7 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>& } } } - if (NotifyHeaderTip()) { + if (NotifyHeaderTip(::ChainstateActive())) { if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) { LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); } @@ -3800,7 +3801,7 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s } } - NotifyHeaderTip(); + NotifyHeaderTip(::ChainstateActive()); BlockValidationState state; // Only used to report errors, not invalidity - ignore it if (!::ChainstateActive().ActivateBestChain(state, chainparams, pblock)) @@ -4685,7 +4686,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi } } - NotifyHeaderTip(); + NotifyHeaderTip(::ChainstateActive()); // Recursively process earlier encountered successors of this block std::deque<uint256> queue; @@ -4711,7 +4712,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi } range.first++; mapBlocksUnknownParent.erase(it); - NotifyHeaderTip(); + NotifyHeaderTip(::ChainstateActive()); } } } catch (const std::exception& e) { |