Auto merge of #1047 - aniemerg:fix/get-difficulty-fix2, r=ebfull

Update GetDifficulty() to use consensus.powLimit from consensus parameters.

Fixes #1032.
This commit is contained in:
zkbot 2016-07-14 04:18:56 +00:00
commit 4bcdd85583
1 changed files with 7 additions and 3 deletions

View File

@ -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--;