Allow minimum-difficulty blocks on testnet and regtest

A block may be mined with nBits set to the minimum difficulty if its
nTime is set more than six block intervals (15 minutes) after its parent
block.

This is a consensus rule change on testnet that will result in a chain
split (as desired).
This commit is contained in:
Jack Grigg
2018-10-03 17:50:17 +01:00
parent 639e46b4d7
commit 1702a86455
4 changed files with 52 additions and 52 deletions

View File

@@ -24,20 +24,14 @@ 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
// If the new block's timestamp is more than 6 * 2.5 minutes
// then allow mining of a min-difficulty block.
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
if (pblock && pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing * 6)
return nProofOfWorkLimit;
else {
// Get the last non-min-difficulty (or at worst the genesis difficulty)
while (pindexBits->pprev && pindexBits->nBits == nProofOfWorkLimit)
pindexBits = pindexBits->pprev;
}
}
}