diff --git a/src/consensus/params.h b/src/consensus/params.h index 72d4d6729..bc3d7c75d 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -67,6 +67,7 @@ struct Params { int64_t nProtocolV1RetargetingFixedTime; int64_t nProtocolV2Time; int64_t nProtocolV3Time; + bool IsProtocolV1RetargetingFixed(int64_t nTime) const { return nTime > nProtocolV1RetargetingFixedTime && nTime != 1395631999; } bool IsProtocolV2(int64_t nTime) const { return nTime > nProtocolV2Time && nTime != 1407053678; } bool IsProtocolV3(int64_t nTime) const { return nTime > nProtocolV3Time && nTime != 1444028400; } unsigned int GetTargetSpacing(int nHeight) { return IsProtocolV2(nHeight) ? 64 : 60; } diff --git a/src/main.cpp b/src/main.cpp index 6e9a6d502..dd902529d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2340,7 +2340,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin pindex->nStakeModifier = ComputeStakeModifier(pindex->pprev, block.IsProofOfStake() ? block.vtx[1].vin[0].prevout.hash : block.GetHash()); // Check proof-of-stake - if (block.IsProofOfStake() && block.GetBlockTime() > chainparams.GetConsensus().nProtocolV3Time) { + if (block.IsProofOfStake() && chainparams.GetConsensus().IsProtocolV3(block.GetBlockTime())) { const COutPoint &prevout = block.vtx[1].vin[0].prevout; const CCoins *coins = view.AccessCoins(prevout.hash); if (!coins) @@ -2416,7 +2416,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin flags |= SCRIPT_VERIFY_LOW_S; // Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) since protocol v3 - if (block.GetBlockTime() > chainparams.GetConsensus().nProtocolV3Time) { + if (chainparams.GetConsensus().IsProtocolV3(block.GetBlockTime())) { flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; flags |= SCRIPT_VERIFY_NULLDUMMY; } @@ -2518,7 +2518,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin REJECT_INVALID, "bad-cb-amount"); } - if (block.IsProofOfStake() && block.GetBlockTime() > chainparams.GetConsensus().nProtocolV3Time) { + if (block.IsProofOfStake() && chainparams.GetConsensus().IsProtocolV3(block.GetBlockTime())) { CAmount blockReward = nFees + GetProofOfStakeSubsidy(); if (nActualStakeReward > blockReward) return state.DoS(100, diff --git a/src/pow.cpp b/src/pow.cpp index ca2f8b1b0..ab0d7041d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -61,9 +61,9 @@ unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t int64_t nActualSpacing = pindexLast->GetBlockTime() - nFirstBlockTime; // Limit adjustment step - if (pindexLast->GetBlockTime() > params.nProtocolV1RetargetingFixedTime && nActualSpacing < 0) + if (params.IsProtocolV1RetargetingFixed(pindexLast->GetBlockTime()) && nActualSpacing < 0) nActualSpacing = nTargetSpacing; - if (pindexLast->GetBlockTime() > params.nProtocolV3Time && nActualSpacing > nTargetSpacing*10) + if (params.IsProtocolV3(pindexLast->GetBlockTime()) && nActualSpacing > nTargetSpacing*10) nActualSpacing = nTargetSpacing*10; // retarget with exponential moving toward target spacing