Skip to content

Commit 0cdad75

Browse files
committed
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.
1 parent ea4fed9 commit 0cdad75

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/validation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,6 +3775,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
37753775
bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing, bool* fNewBlock)
37763776
{
37773777
AssertLockNotHeld(cs_main);
3778+
assert(std::addressof(::ChainstateActive()) == std::addressof(ActiveChainstate()));
37783779

37793780
{
37803781
CBlockIndex *pindex = nullptr;
@@ -3790,18 +3791,18 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
37903791
bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus());
37913792
if (ret) {
37923793
// Store to disk
3793-
ret = ::ChainstateActive().AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock);
3794+
ret = ActiveChainstate().AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, nullptr, fNewBlock);
37943795
}
37953796
if (!ret) {
37963797
GetMainSignals().BlockChecked(*pblock, state);
37973798
return error("%s: AcceptBlock FAILED (%s)", __func__, state.ToString());
37983799
}
37993800
}
38003801

3801-
NotifyHeaderTip(::ChainstateActive());
3802+
NotifyHeaderTip(ActiveChainstate());
38023803

38033804
BlockValidationState state; // Only used to report errors, not invalidity - ignore it
3804-
if (!::ChainstateActive().ActivateBestChain(state, chainparams, pblock))
3805+
if (!ActiveChainstate().ActivateBestChain(state, chainparams, pblock))
38053806
return error("%s: ActivateBestChain failed (%s)", __func__, state.ToString());
38063807

38073808
return true;

0 commit comments

Comments
 (0)