Skip to content

Commit 050cabd

Browse files
authored
Adjust diff for slow testnet/devnet blocks a bit smoother (#2161)
* Adjust diff for slow testnet/devnet blocks a bit smoother * bump to 000000000000000000000000000000000000000000000000003ff00000000000 * bump slow blocks to 10 minutes
1 parent c4698d5 commit 050cabd

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/pow.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,25 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH
103103
// Special difficulty rule for testnet/devnet:
104104
// If the new block's timestamp is more than 2* 2.5 minutes
105105
// then allow mining of a min-difficulty block.
106-
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
107-
return bnPowLimit.GetCompact();
106+
107+
// start using smoother adjustment on testnet when total work hits
108+
// 000000000000000000000000000000000000000000000000003ff00000000000
109+
if (pindexLast->nChainWork >= UintToArith256(uint256S("0x000000000000000000000000000000000000000000000000003ff00000000000"))
110+
// and immediately on devnet
111+
|| !params.hashDevnetGenesisBlock.IsNull()) {
112+
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*4) {
113+
arith_uint256 bnNew = arith_uint256().SetCompact(pindexLast->nBits) * 10;
114+
if (bnNew > bnPowLimit) {
115+
bnNew = bnPowLimit;
116+
}
117+
return bnNew.GetCompact();
118+
}
119+
} else {
120+
// old stuff
121+
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2) {
122+
return bnPowLimit.GetCompact();
123+
}
124+
}
108125
}
109126

110127
const CBlockIndex *pindex = pindexLast;

0 commit comments

Comments
 (0)