| 155 | } |
| 156 | |
| 157 | int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params) |
| 158 | { |
| 159 | arith_uint256 r; |
| 160 | int sign = 1; |
| 161 | if (to.nChainWork > from.nChainWork) { |
| 162 | r = to.nChainWork - from.nChainWork; |
| 163 | } else { |
| 164 | r = from.nChainWork - to.nChainWork; |
| 165 | sign = -1; |
| 166 | } |
| 167 | r = r * arith_uint256(params.nPowTargetSpacing) / GetBlockProof(tip); |
| 168 | if (r.bits() > 63) { |
| 169 | return sign * std::numeric_limits<int64_t>::max(); |
| 170 | } |
| 171 | return sign * r.GetLow64(); |
| 172 | } |