MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / GetSkipHeight

Function GetSkipHeight

src/main.cpp:2018–2026  ·  view source on GitHub ↗

Compute what height to jump back to with the CBlockIndex::pskip pointer. */

Source from the content-addressed store, hash-verified

2016
2017/** Compute what height to jump back to with the CBlockIndex::pskip pointer. */
2018int32_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
2028CBlockIndex *CBlockIndex::GetAncestor(int32_t heightIn) {
2029 if (heightIn > height || heightIn < 0)

Callers 2

GetAncestorMethod · 0.85
BuildSkipMethod · 0.85

Calls 1

InvertLowestOneFunction · 0.85

Tested by

no test coverage detected