mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Remove temporary fork handling for emergency difficulty reduction on testnet
As we reset testnet, we can also remove the special handling for old blocks.
This commit is contained in:
parent
db4f43f874
commit
0fca0e6fc8
29
src/pow.cpp
29
src/pow.cpp
@ -89,44 +89,19 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH
|
|||||||
return bnPowLimit.GetCompact();
|
return bnPowLimit.GetCompact();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.fPowAllowMinDifficultyBlocks && (
|
if (params.fPowAllowMinDifficultyBlocks) {
|
||||||
// testnet ...
|
|
||||||
(params.hashDevnetGenesisBlock.IsNull() && pindexLast->nChainWork >= UintToArith256(uint256S("0x000000000000000000000000000000000000000000000000003e9ccfe0e03e01"))) ||
|
|
||||||
// or devnet
|
|
||||||
!params.hashDevnetGenesisBlock.IsNull())) {
|
|
||||||
// NOTE: 000000000000000000000000000000000000000000000000003e9ccfe0e03e01 is the work of the "wrong" chain,
|
|
||||||
// so this rule activates there immediately and new blocks with high diff from that chain are going
|
|
||||||
// to be rejected by updated nodes. Note, that old nodes are going to reject blocks from updated nodes
|
|
||||||
// after the "right" chain reaches this amount of work too. This is a temporary condition which should
|
|
||||||
// be removed when we decide to hard-fork testnet again.
|
|
||||||
// TODO: remove "testnet+work OR devnet" part on next testnet hard-fork
|
|
||||||
// Special difficulty rule for testnet/devnet:
|
|
||||||
// If the new block's timestamp is more than 2* 2.5 minutes
|
|
||||||
// then allow mining of a min-difficulty block.
|
|
||||||
|
|
||||||
// start using smoother adjustment on testnet when total work hits
|
|
||||||
// 000000000000000000000000000000000000000000000000003ff00000000000
|
|
||||||
if (pindexLast->nChainWork >= UintToArith256(uint256S("0x000000000000000000000000000000000000000000000000003ff00000000000"))
|
|
||||||
// and immediately on devnet
|
|
||||||
|| !params.hashDevnetGenesisBlock.IsNull()) {
|
|
||||||
// recent block is more than 2 hours old
|
// recent block is more than 2 hours old
|
||||||
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + 2 * 60 * 60) {
|
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + 2 * 60 * 60) {
|
||||||
return bnPowLimit.GetCompact();
|
return bnPowLimit.GetCompact();
|
||||||
}
|
}
|
||||||
// recent block is more than 10 minutes old
|
// recent block is more than 10 minutes old
|
||||||
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*4) {
|
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing * 4) {
|
||||||
arith_uint256 bnNew = arith_uint256().SetCompact(pindexLast->nBits) * 10;
|
arith_uint256 bnNew = arith_uint256().SetCompact(pindexLast->nBits) * 10;
|
||||||
if (bnNew > bnPowLimit) {
|
if (bnNew > bnPowLimit) {
|
||||||
bnNew = bnPowLimit;
|
bnNew = bnPowLimit;
|
||||||
}
|
}
|
||||||
return bnNew.GetCompact();
|
return bnNew.GetCompact();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// old stuff
|
|
||||||
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2) {
|
|
||||||
return bnPowLimit.GetCompact();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CBlockIndex *pindex = pindexLast;
|
const CBlockIndex *pindex = pindexLast;
|
||||||
|
Loading…
Reference in New Issue
Block a user