Calculate the difficulty for a given block index. */
| 81 | /* Calculate the difficulty for a given block index. |
| 82 | */ |
| 83 | double GetDifficulty(const CBlockIndex* blockindex) |
| 84 | { |
| 85 | CHECK_NONFATAL(blockindex); |
| 86 | |
| 87 | int nShift = (blockindex->nBits >> 24) & 0xff; |
| 88 | double dDiff = |
| 89 | (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); |
| 90 | |
| 91 | while (nShift < 29) |
| 92 | { |
| 93 | dDiff *= 256.0; |
| 94 | nShift++; |
| 95 | } |
| 96 | while (nShift > 29) |
| 97 | { |
| 98 | dDiff /= 256.0; |
| 99 | nShift--; |
| 100 | } |
| 101 | |
| 102 | return dDiff; |
| 103 | } |
| 104 | |
| 105 | UniValue paramEntryToJSON(const DynaFedParamEntry& entry) |
| 106 | { |
no outgoing calls