Browse Source

Difficulty 1 is: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

cn
Jianping Wu 6 years ago
parent
commit
2d8820811e
  1. 8
      src/rpc/blockchain.cpp

8
src/rpc/blockchain.cpp

@ -63,15 +63,17 @@ double GetDifficulty(const CChain& chain, const CBlockIndex* blockindex) @@ -63,15 +63,17 @@ double GetDifficulty(const CChain& chain, const CBlockIndex* blockindex)
}
int nShift = (blockindex->nBits >> 24) & 0xff;
// Difficulty 1 is: 0x2100ffff
double dDiff =
(double)0x0ffff0 / (double)(blockindex->nBits & 0x00ffffff);
(double)0x00ffff / (double)(blockindex->nBits & 0x00ffffff);
while (nShift < 31)
while (nShift < 33)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 31)
while (nShift > 33)
{
dDiff /= 256.0;
nShift--;

Loading…
Cancel
Save