@@ -3809,25 +3809,27 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
3809
3809
return true ;
3810
3810
}
3811
3811
3812
- bool TestBlockValidity (BlockValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW , bool fCheckMerkleRoot )
3812
+ bool TestBlockValidity (BlockValidationState& state, const CChainParams& chainparams, CChainState& chainstate, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW , bool fCheckMerkleRoot )
3813
3813
{
3814
3814
AssertLockHeld (cs_main);
3815
- assert (pindexPrev && pindexPrev == ::ChainActive ().Tip ());
3816
- CCoinsViewCache viewNew (&::ChainstateActive ().CoinsTip ());
3815
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (chainstate));
3816
+ assert (pindexPrev && pindexPrev == chainstate.m_chain .Tip ());
3817
+ CCoinsViewCache viewNew (&chainstate.CoinsTip ());
3817
3818
uint256 block_hash (block.GetHash ());
3818
3819
CBlockIndex indexDummy (block);
3819
3820
indexDummy.pprev = pindexPrev;
3820
3821
indexDummy.nHeight = pindexPrev->nHeight + 1 ;
3821
3822
indexDummy.phashBlock = &block_hash;
3822
3823
3823
3824
// NOTE: CheckBlockHeader is called by CheckBlock
3824
- if (!ContextualCheckBlockHeader (block, state, g_chainman.m_blockman , chainparams, pindexPrev, GetAdjustedTime ()))
3825
+ assert (std::addressof (g_chainman.m_blockman ) == std::addressof (chainstate.m_blockman ));
3826
+ if (!ContextualCheckBlockHeader (block, state, chainstate.m_blockman , chainparams, pindexPrev, GetAdjustedTime ()))
3825
3827
return error (" %s: Consensus::ContextualCheckBlockHeader: %s" , __func__, state.ToString ());
3826
3828
if (!CheckBlock (block, state, chainparams.GetConsensus (), fCheckPOW , fCheckMerkleRoot ))
3827
3829
return error (" %s: Consensus::CheckBlock: %s" , __func__, state.ToString ());
3828
3830
if (!ContextualCheckBlock (block, state, chainparams.GetConsensus (), pindexPrev))
3829
3831
return error (" %s: Consensus::ContextualCheckBlock: %s" , __func__, state.ToString ());
3830
- if (!:: ChainstateActive () .ConnectBlock (block, state, &indexDummy, viewNew, chainparams, true ))
3832
+ if (!chainstate .ConnectBlock (block, state, &indexDummy, viewNew, chainparams, true ))
3831
3833
return false ;
3832
3834
assert (state.IsValid ());
3833
3835
0 commit comments