Merge pull request #340 from romanornr/master

Litecoin: Zeitgeist2 bool fshift bnNew.bits()
This commit is contained in:
Adrian Gallagher 2017-07-23 18:11:27 +10:00 committed by GitHub
commit 6c433835a8

View File

@ -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
if (fShift)
bnNew <<= 1;
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
if (bnNew > bnPowLimit)
bnNew = bnPowLimit;