Litecoin: Zeitgeist2 bool fshift bnNew.bits()

This commit is contained in:
romanornr 2017-07-08 12:10:01 +02:00 committed by Adrian Gallagher
parent 293d7cac1d
commit e9801c248d
No known key found for this signature in database
GPG Key ID: FE3348877809386C

View File

@ -73,7 +73,8 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
bnNew.SetCompact(pindexLast->nBits); bnNew.SetCompact(pindexLast->nBits);
bnOld = bnNew; bnOld = bnNew;
// Litecoin: intermediate uint256 can overflow by 1 bit // 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) if (fShift)
bnNew >>= 1; bnNew >>= 1;
bnNew *= nActualTimespan; bnNew *= nActualTimespan;
@ -81,7 +82,6 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
if (fShift) if (fShift)
bnNew <<= 1; bnNew <<= 1;
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
if (bnNew > bnPowLimit) if (bnNew > bnPowLimit)
bnNew = bnPowLimit; bnNew = bnPowLimit;