From b338987d94210bcda3dee171bf1d0c5070bb94ba Mon Sep 17 00:00:00 2001 From: lateminer Date: Thu, 11 Oct 2018 22:56:04 +0300 Subject: [PATCH] Move block height check from ContextualCheckBlock() to ConnectBlock() --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d37596fed..bbb3be712 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2413,6 +2413,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; } + // Reject proof-of-work after nLastPOWBlock + if (block.IsProofOfWork() && pindex->nHeight > chainparams.GetConsensus().nLastPOWBlock) + return state.DoS(100, error("%s: reject proof-of-work at height %d", __func__, pindex->nHeight), + REJECT_INVALID, "bad-pow-height"); + // Check difficulty if (block.nBits != GetNextTargetRequired(pindex->pprev, &block, block.IsProofOfStake(), chainparams.GetConsensus())) return state.DoS(100, error("%s: incorrect difficulty", __func__), @@ -3714,9 +3719,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; const Consensus::Params& consensusParams = Params().GetConsensus(); - if (block.IsProofOfWork() && nHeight > consensusParams.nLastPOWBlock) - return state.DoS(100, error("%s : reject proof-of-work at height %d", __func__, nHeight), REJECT_INVALID, "bad-pow-height"); - // Start enforcing BIP113 (Median Time Past) using versionbits logic. int nLockTimeFlags = 0;