Only enable min-difficulty blocks on testnet from a particular height
The min-difficulty change is a bilateral consensus rule change, and so must be conditionally enabled in order for the earlier section of the chain to synchronise. Technically this could be implemented as a network upgrade, but as this will never be deployed to mainnet, a targeted fork will suffice.
This commit is contained in:
@@ -103,8 +103,9 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
||||
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||
|
||||
// Updating time can change work required on testnet:
|
||||
if (consensusParams.fPowAllowMinDifficultyBlocks)
|
||||
if (consensusParams.nPowAllowMinDifficultyBlocksFromHeight) {
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
|
||||
}
|
||||
}
|
||||
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
@@ -726,7 +727,7 @@ void static BitcoinMiner()
|
||||
// Update nNonce and nTime
|
||||
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
if (chainparams.GetConsensus().fPowAllowMinDifficultyBlocks)
|
||||
if (chainparams.GetConsensus().nPowAllowMinDifficultyBlocksFromHeight)
|
||||
{
|
||||
// Changing pblock->nTime can change work required on testnet:
|
||||
hashTarget.SetCompact(pblock->nBits);
|
||||
|
||||
Reference in New Issue
Block a user