diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -586,14 +586,12 @@ const Config &config, const CTransaction &tx, CValidationState &state, const Consensus::Params &consensusParams, int flags = -1); -/** Context-dependent validity checks. - * By "context", we mean only the previous block headers, but not the UTXO - * set; UTXO-related validity checks are done in ConnectBlock(). */ -bool ContextualCheckBlockHeader(const CBlockHeader &block, - CValidationState &state, - const Consensus::Params &consensusParams, - const CBlockIndex *pindexPrev, - int64_t nAdjustedTime); +/** + * Context-dependent validity checks. + * + * By "context", we mean only the previous block headers, but not the UTXO set; + * UTXO-related validity checks are done in ConnectBlock(). + */ bool ContextualCheckBlock(const Config &config, const CBlock &block, CValidationState &state, const Consensus::Params &consensusParams, diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3343,11 +3343,14 @@ return true; } -bool ContextualCheckBlockHeader(const CBlockHeader &block, - CValidationState &state, - const Consensus::Params &consensusParams, - const CBlockIndex *pindexPrev, - int64_t nAdjustedTime) { +static bool ContextualCheckBlockHeader(const Config &config, + const CBlockHeader &block, + CValidationState &state, + const CBlockIndex *pindexPrev, + int64_t nAdjustedTime) { + const Consensus::Params &consensusParams = + config.GetChainParams().GetConsensus(); + const int nHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1; // Check proof of work @@ -3535,8 +3538,7 @@ state.GetRejectReason().c_str()); } - if (!ContextualCheckBlockHeader(block, state, - chainparams.GetConsensus(), pindexPrev, + if (!ContextualCheckBlockHeader(config, block, state, pindexPrev, GetAdjustedTime())) { return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s", __func__, hash.ToString(), FormatStateMessage(state)); @@ -3761,8 +3763,8 @@ indexDummy.nHeight = pindexPrev->nHeight + 1; // NOTE: CheckBlockHeader is called by CheckBlock - if (!ContextualCheckBlockHeader(block, state, chainparams.GetConsensus(), - pindexPrev, GetAdjustedTime())) { + if (!ContextualCheckBlockHeader(config, block, state, pindexPrev, + GetAdjustedTime())) { return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, FormatStateMessage(state)); }