Move block height check from ContextualCheckBlock() to ConnectBlock()

This commit is contained in:
lateminer
2018-10-11 22:56:04 +03:00
parent b1bb30cb3a
commit b338987d94

View File

@@ -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;