aboutsummaryrefslogtreecommitdiff
path: root/src/pow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pow.cpp')
-rw-r--r--src/pow.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pow.cpp b/src/pow.cpp
index e91e3d893c..90bbff0a33 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -5,6 +5,7 @@
#include "pow.h"
+#include "arith_uint256.h"
#include "chain.h"
#include "chainparams.h"
#include "primitives/block.h"
@@ -56,8 +57,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
nActualTimespan = Params().TargetTimespan()*4;
// Retarget
- uint256 bnNew;
- uint256 bnOld;
+ arith_uint256 bnNew;
+ arith_uint256 bnOld;
bnNew.SetCompact(pindexLast->nBits);
bnOld = bnNew;
bnNew *= nActualTimespan;
@@ -79,7 +80,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
{
bool fNegative;
bool fOverflow;
- uint256 bnTarget;
+ arith_uint256 bnTarget;
if (Params().SkipProofOfWorkCheck())
return true;
@@ -91,22 +92,22 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
return error("CheckProofOfWork() : nBits below minimum work");
// Check proof of work matches claimed amount
- if (hash > bnTarget)
+ if (UintToArith256(hash) > bnTarget)
return error("CheckProofOfWork() : hash doesn't match nBits");
return true;
}
-uint256 GetBlockProof(const CBlockIndex& block)
+arith_uint256 GetBlockProof(const CBlockIndex& block)
{
- uint256 bnTarget;
+ arith_uint256 bnTarget;
bool fNegative;
bool fOverflow;
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
if (fNegative || fOverflow || bnTarget == 0)
return 0;
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
- // as it's too large for a uint256. However, as 2**256 is at least as large
+ // as it's too large for a arith_uint256. However, as 2**256 is at least as large
// as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1,
// or ~bnTarget / (nTarget+1) + 1.
return (~bnTarget / (bnTarget + 1)) + 1;