From 0cdad753903640ff4240b715dec9d62f68e51407 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 26 Aug 2020 14:44:47 -0400 Subject: [PATCH] validation: Use accessible chainstate in ChainstateManager::ProcessNewBlock [META] This commit should be followed up by removing the comments and assertions meant only to show that the change is correct. --- src/validation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index d9453e46a92..0219a4c32d3 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3775,6 +3775,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr& pblock, Block bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr pblock, bool fForceProcessing, bool* fNewBlock) { AssertLockNotHeld(cs_main); + assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate())); { CBlockIndex *pindex = nullptr; @@ -3790,7 +3791,7 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus()); if (ret) { // Store to disk - ret = ::ChainstateActive().AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock); + ret = ActiveChainstate().AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock); } if (!ret) { GetMainSignals().BlockChecked(*pblock, state); @@ -3798,10 +3799,10 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s } } - NotifyHeaderTip(::ChainstateActive()); + NotifyHeaderTip(ActiveChainstate()); BlockValidationState state; // Only used to report errors, not invalidity - ignore it - if (!::ChainstateActive().ActivateBestChain(state, chainparams, pblock)) + if (!ActiveChainstate().ActivateBestChain(state, chainparams, pblock)) return error("%s: ActivateBestChain failed (%s)", __func__, state.ToString()); return true;