| 91 | } |
| 92 | |
| 93 | uint256 GetBlockProof(const CBlockIndex& block) |
| 94 | { |
| 95 | uint256 bnTarget; |
| 96 | bool fNegative; |
| 97 | bool fOverflow; |
| 98 | bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); |
| 99 | if (fNegative || fOverflow || bnTarget == 0) |
| 100 | return 0; |
| 101 | // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 |
| 102 | // as it's too large for a uint256. However, as 2**256 is at least as large |
| 103 | // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1, |
| 104 | // or ~bnTarget / (nTarget+1) + 1. |
| 105 | return (~bnTarget / (bnTarget + 1)) + 1; |
| 106 | } |
no outgoing calls
no test coverage detected