Skip to content

Commit

Permalink
Monacoin: Zeitgeist2 bool fshift bnNew.bits()
Browse files Browse the repository at this point in the history
  • Loading branch information
romanornr authored and monacoinproject committed Aug 1, 2017
1 parent 80512c2 commit 6d65019
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
bnNew.SetCompact(pindexLast->nBits);
bnOld = bnNew;
// Monacoin: intermediate uint256 can overflow by 1 bit
bool fShift = bnNew.bits() > 235;
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
bool fShift = bnNew.bits() > bnPowLimit.bits() - 1;
if (fShift)
bnNew >>= 1;
bnNew *= nActualTimespan;
bnNew /= targetTimespan;
if (fShift)
bnNew <<= 1;

const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
if (bnNew > bnPowLimit)
bnNew = bnPowLimit;

Expand Down

0 comments on commit 6d65019

Please sign in to comment.