Compute what height to jump back to with the CBlockIndex::pskip pointer. */
| 2016 | |
| 2017 | /** Compute what height to jump back to with the CBlockIndex::pskip pointer. */ |
| 2018 | int32_t static inline GetSkipHeight(int32_t height) { |
| 2019 | if (height < 2) |
| 2020 | return 0; |
| 2021 | |
| 2022 | // Determine which height to jump back to. Any number strictly lower than height is acceptable, |
| 2023 | // but the following expression seems to perform well in simulations (max 110 steps to go back |
| 2024 | // up to 2**18 blocks). |
| 2025 | return (height & 1) ? InvertLowestOne(InvertLowestOne(height - 1)) + 1 : InvertLowestOne(height); |
| 2026 | } |
| 2027 | |
| 2028 | CBlockIndex *CBlockIndex::GetAncestor(int32_t heightIn) { |
| 2029 | if (heightIn > height || heightIn < 0) |
no test coverage detected