| 119 | } |
| 120 | |
| 121 | arith_uint256 GetBlockProof(const CBlockIndex& block) |
| 122 | { |
| 123 | arith_uint256 bnTarget; |
| 124 | bool fNegative; |
| 125 | bool fOverflow; |
| 126 | bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); |
| 127 | if (fNegative || fOverflow || bnTarget == 0) |
| 128 | return 0; |
| 129 | // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 |
| 130 | // as it's too large for an arith_uint256. However, as 2**256 is at least as large |
| 131 | // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1, |
| 132 | // or ~bnTarget / (bnTarget+1) + 1. |
| 133 | return (~bnTarget / (bnTarget + 1)) + 1; |
| 134 | } |
| 135 | |
| 136 | int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params) |
| 137 | { |
no outgoing calls