Revert "Remove testnet-only difficulty rules"

This reverts commit 333ea3c426.
This commit is contained in:
Jack Grigg
2018-10-03 16:15:03 +01:00
parent 5ead4b1713
commit 639e46b4d7
3 changed files with 61 additions and 9 deletions

View File

@@ -24,6 +24,23 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
if (pindexLast == NULL)
return nProofOfWorkLimit;
const CBlockIndex* pindexBits = pindexLast;
{
if (params.fPowAllowMinDifficultyBlocks)
{
// Special difficulty rule for testnet:
// If the new block's timestamp is more than 2* 2.5 minutes
// then allow mining of a min-difficulty block.
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
return nProofOfWorkLimit;
else {
// Get the last non-min-difficulty (or at worst the genesis difficulty)
while (pindexBits->pprev && pindexBits->nBits == nProofOfWorkLimit)
pindexBits = pindexBits->pprev;
}
}
}
// Find the first block in the averaging interval
const CBlockIndex* pindexFirst = pindexLast;
arith_uint256 bnTot {0};