mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
testnet: Add Testnet4 difficulty adjustment rules fix
This commit is contained in:
parent
74a04f9e7a
commit
0100907ca1
1 changed files with 13 additions and 1 deletions
14
src/pow.cpp
14
src/pow.cpp
|
@ -61,7 +61,19 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
|
|||
// Retarget
|
||||
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
|
||||
arith_uint256 bnNew;
|
||||
bnNew.SetCompact(pindexLast->nBits);
|
||||
|
||||
// Special difficulty rule for Testnet4
|
||||
if (params.enforce_BIP94) {
|
||||
// Here we use the first block of the difficulty period. This way
|
||||
// the real difficulty is always preserved in the first block as
|
||||
// it is not allowed to use the min-difficulty exception.
|
||||
int nHeightFirst = pindexLast->nHeight - (params.DifficultyAdjustmentInterval()-1);
|
||||
const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst);
|
||||
bnNew.SetCompact(pindexFirst->nBits);
|
||||
} else {
|
||||
bnNew.SetCompact(pindexLast->nBits);
|
||||
}
|
||||
|
||||
bnNew *= nActualTimespan;
|
||||
bnNew /= params.nPowTargetTimespan;
|
||||
|
||||
|
|
Loading…
Reference in a new issue