| 140 | } |
| 141 | |
| 142 | arith_uint256 GetBlockProof(const CBlockIndex& block) |
| 143 | { |
| 144 | arith_uint256 bnTarget; |
| 145 | bool fNegative; |
| 146 | bool fOverflow; |
| 147 | bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); |
| 148 | if (fNegative || fOverflow || bnTarget == 0) |
| 149 | return 0; |
| 150 | // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 |
| 151 | // as it's too large for a arith_uint256. However, as 2**256 is at least as large |
| 152 | // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1, |
| 153 | // or ~bnTarget / (nTarget+1) + 1. |
| 154 | return (~bnTarget / (bnTarget + 1)) + 1; |
| 155 | } |
| 156 | |
| 157 | int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params) |
| 158 | { |
no outgoing calls