Calculate the difficulty for a given block index. */
| 104 | /* Calculate the difficulty for a given block index. |
| 105 | */ |
| 106 | double GetDifficulty(const CBlockIndex& blockindex) |
| 107 | { |
| 108 | int nShift = (blockindex.nBits >> 24) & 0xff; |
| 109 | double dDiff = |
| 110 | (double)0x0000ffff / (double)(blockindex.nBits & 0x00ffffff); |
| 111 | |
| 112 | while (nShift < 29) |
| 113 | { |
| 114 | dDiff *= 256.0; |
| 115 | nShift++; |
| 116 | } |
| 117 | while (nShift > 29) |
| 118 | { |
| 119 | dDiff /= 256.0; |
| 120 | nShift--; |
| 121 | } |
| 122 | |
| 123 | return dDiff; |
| 124 | } |
| 125 | |
| 126 | static int ComputeNextBlockAndDepth(const CBlockIndex& tip, const CBlockIndex& blockindex, const CBlockIndex*& next) |
| 127 | { |
no outgoing calls