This might be the most important piece of code in the history of Programming:

```

/* Calculate the difficulty for a given block index.

*/

double GetDifficulty(const CBlockIndex& blockindex)

{

int nShift = (blockindex.nBits >> 24) & 0xff;

double dDiff =

(double)0x0000ffff / (double)(blockindex.nBits & 0x00ffffff);

while (nShift < 29)

{

dDiff *= 256.0;

nShift++;

}

while (nShift > 29)

{

dDiff /= 256.0;

nShift--;

}

return dDiff;

}

```

#Bitcoin

Reply to this note

Please Login to reply.

Discussion

No replies yet.