Browse Source

Update GetDifficulty() to use consensus.powLimit from consensus parameters. Fixes #1032.

pull/145/head
aniemerg 8 years ago
parent
commit
24809b16b6
  1. 10
      src/rpcblockchain.cpp

10
src/rpcblockchain.cpp

@ -34,16 +34,20 @@ double GetDifficulty(const CBlockIndex* blockindex)
}
int nShift = (blockindex->nBits >> 24) & 0xff;
uint32_t powLimit =
UintToArith256(Params().GetConsensus().powLimit).GetCompact();;
int nShiftAmount = (powLimit >> 24) & 0xff;
double dDiff =
(double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
(double)(powLimit & 0x00ffffff) /
(double)(blockindex->nBits & 0x00ffffff);
while (nShift < 29)
while (nShift < nShiftAmount)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 29)
while (nShift > nShiftAmount)
{
dDiff /= 256.0;
nShift--;

Loading…
Cancel
Save