diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-04-13 10:40:13 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-04-13 11:25:01 +0200 |
| commit | 9125c08f3468928eba004636bd95494a94e1a82b (patch) | |
| tree | 6355de7f0bac3e37d9c48fd4b310bf7bccd71ea7 /src/pow.cpp | |
| parent | Merge pull request #5983 (diff) | |
| parent | consensus: don't use arith_uint256 in consensus.h (diff) | |
| download | discoin-9125c08f3468928eba004636bd95494a94e1a82b.tar.xz discoin-9125c08f3468928eba004636bd95494a94e1a82b.zip | |
Merge pull request #6000
fd31199 consensus: don't use arith_uint256 in consensus.h (Cory Fields)
Diffstat (limited to 'src/pow.cpp')
| -rw-r--r-- | src/pow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pow.cpp b/src/pow.cpp index cf7ac387f..fc6ed4f3d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -13,7 +13,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - unsigned int nProofOfWorkLimit = params.powLimit.GetCompact(); + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block if (pindexLast == NULL) @@ -61,6 +61,7 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF nActualTimespan = params.nPowTargetTimespan*4; // Retarget + const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); arith_uint256 bnNew; arith_uint256 bnOld; bnNew.SetCompact(pindexLast->nBits); @@ -68,8 +69,8 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF bnNew *= nActualTimespan; bnNew /= params.nPowTargetTimespan; - if (bnNew > params.powLimit) - bnNew = params.powLimit; + if (bnNew > bnPowLimit) + bnNew = bnPowLimit; /// debug print LogPrintf("GetNextWorkRequired RETARGET\n"); @@ -89,7 +90,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& bnTarget.SetCompact(nBits, &fNegative, &fOverflow); // Check range - if (fNegative || bnTarget == 0 || fOverflow || bnTarget > params.powLimit) + if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); // Check proof of work matches claimed amount |