File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,19 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
61
61
// Retarget
62
62
const arith_uint256 bnPowLimit = UintToArith256 (params.powLimit );
63
63
arith_uint256 bnNew;
64
- bnNew.SetCompact (pindexLast->nBits );
64
+
65
+ // Special difficulty rule for Testnet4
66
+ if (params.enforce_BIP94 ) {
67
+ // Here we use the first block of the difficulty period. This way
68
+ // the real difficulty is always preserved in the first block as
69
+ // it is not allowed to use the min-difficulty exception.
70
+ int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval ()-1 );
71
+ const CBlockIndex* pindexFirst = pindexLast->GetAncestor (nHeightFirst);
72
+ bnNew.SetCompact (pindexFirst->nBits );
73
+ } else {
74
+ bnNew.SetCompact (pindexLast->nBits );
75
+ }
76
+
65
77
bnNew *= nActualTimespan;
66
78
bnNew /= params.nPowTargetTimespan ;
67
79
You can’t perform that action at this time.
0 commit comments