Browse Source

Litecoin: Zeitgeist2 bool fshift bnNew.bits()

0.14^2
romanornr 7 years ago
parent
commit
51a59d4bef
No known key found for this signature in database
GPG Key ID: 3F92368F0D21A206
  1. 4
      src/pow.cpp

4
src/pow.cpp

@ -76,7 +76,8 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF @@ -76,7 +76,8 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
bnNew.SetCompact(pindexLast->nBits);
bnOld = bnNew;
// Litecoin: 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;
@ -84,7 +85,6 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF @@ -84,7 +85,6 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
if (fShift)
bnNew <<= 1;
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
if (bnNew > bnPowLimit)
bnNew = bnPowLimit;

Loading…
Cancel
Save