| 149 | } |
| 150 | |
| 151 | arith_uint256 GetBlockProof(const CBlockIndex& block) |
| 152 | { |
| 153 | // All valid signed blocks have "weight" 1 |
| 154 | if (g_signed_blocks) { |
| 155 | return 1; |
| 156 | } |
| 157 | |
| 158 | arith_uint256 bnTarget; |
| 159 | bool fNegative; |
| 160 | bool fOverflow; |
| 161 | bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); |
| 162 | if (fNegative || fOverflow || bnTarget == 0) |
| 163 | return 0; |
| 164 | // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256 |
| 165 | // as it's too large for an arith_uint256. However, as 2**256 is at least as large |
| 166 | // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1, |
| 167 | // or ~bnTarget / (bnTarget+1) + 1. |
| 168 | return (~bnTarget / (bnTarget + 1)) + 1; |
| 169 | } |
| 170 | |
| 171 | int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params) |
| 172 | { |
no outgoing calls