diff options
author | Carl Dong <contact@carldong.me> | 2020-08-26 14:44:47 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-01-28 14:15:26 -0500 |
commit | 0cdad753903640ff4240b715dec9d62f68e51407 (patch) | |
tree | 0d4cccc7afc8671d7186c4b8d8ebe74bdf89f302 | |
parent | ea4fed90219be17160136313c68c06d84176af08 (diff) |
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.
-rw-r--r-- | src/validation.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index d9453e46a9..0219a4c32d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3775,6 +3775,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> 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; |