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:
10
src/pow.cpp
10
src/pow.cpp
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user