Skip to content

Commit

Permalink
[Consensus] Fix difficulty adjustment on first block of timeproto V2
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Nov 20, 2019
1 parent c254df6 commit 4ea0476
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
// ppcoin: target change every block
// ppcoin: retarget with exponential moving toward target spacing
uint256 bnNew;
bnNew.SetCompact(pindexLast->nBits);

// on first block with V2 time protocol, reduce the difficulty by a factor 16
if (fTimeV2 && !Params().IsTimeProtocolV2(pindexLast->nHeight)) {
bnNew.SetCompact(pindexLast->nBits << 4);
} else {
bnNew.SetCompact(pindexLast->nBits);
}
if (fTimeV2 && !Params().IsTimeProtocolV2(pindexLast->nHeight))
bnNew <<= 4;

int64_t nInterval = nTargetTimespan / nTargetSpacing;
bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing);
Expand Down

0 comments on commit 4ea0476

Please sign in to comment.