@@ -3426,7 +3426,7 @@ CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
3426
3426
* in ConnectBlock().
3427
3427
* Note that -reindex-chainstate skips the validation that happens here!
3428
3428
*/
3429
- static bool ContextualCheckBlockHeader (const CBlockHeader& block, BlockValidationState& state, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
3429
+ static bool ContextualCheckBlockHeader (const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
3430
3430
{
3431
3431
assert (pindexPrev != nullptr );
3432
3432
const int nHeight = pindexPrev->nHeight + 1 ;
@@ -3441,7 +3441,8 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
3441
3441
// Don't accept any forks from the main chain prior to last checkpoint.
3442
3442
// GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
3443
3443
// BlockIndex().
3444
- CBlockIndex* pcheckpoint = g_chainman.m_blockman .GetLastCheckpoint (params.Checkpoints ());
3444
+ assert (std::addressof (g_chainman.m_blockman ) == std::addressof (blockman));
3445
+ CBlockIndex* pcheckpoint = blockman.GetLastCheckpoint (params.Checkpoints ());
3445
3446
if (pcheckpoint && nHeight < pcheckpoint->nHeight ) {
3446
3447
LogPrintf (" ERROR: %s: forked chain older than last checkpoint (height %d)\n " , __func__, nHeight);
3447
3448
return state.Invalid (BlockValidationResult::BLOCK_CHECKPOINT, " bad-fork-prior-to-checkpoint" );
@@ -3592,7 +3593,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
3592
3593
LogPrintf (" ERROR: %s: prev block invalid\n " , __func__);
3593
3594
return state.Invalid (BlockValidationResult::BLOCK_INVALID_PREV, " bad-prevblk" );
3594
3595
}
3595
- if (!ContextualCheckBlockHeader (block, state, chainparams, pindexPrev, GetAdjustedTime ()))
3596
+ if (!ContextualCheckBlockHeader (block, state, * this , chainparams, pindexPrev, GetAdjustedTime ()))
3596
3597
return error (" %s: Consensus::ContextualCheckBlockHeader: %s, %s" , __func__, hash.ToString (), state.ToString ());
3597
3598
3598
3599
/* Determine if this block descends from any block which has been found
@@ -3820,7 +3821,7 @@ bool TestBlockValidity(BlockValidationState& state, const CChainParams& chainpar
3820
3821
indexDummy.phashBlock = &block_hash;
3821
3822
3822
3823
// NOTE: CheckBlockHeader is called by CheckBlock
3823
- if (!ContextualCheckBlockHeader (block, state, chainparams, pindexPrev, GetAdjustedTime ()))
3824
+ if (!ContextualCheckBlockHeader (block, state, g_chainman. m_blockman , chainparams, pindexPrev, GetAdjustedTime ()))
3824
3825
return error (" %s: Consensus::ContextualCheckBlockHeader: %s" , __func__, state.ToString ());
3825
3826
if (!CheckBlock (block, state, chainparams.GetConsensus (), fCheckPOW , fCheckMerkleRoot ))
3826
3827
return error (" %s: Consensus::CheckBlock: %s" , __func__, state.ToString ());
0 commit comments