MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSkipHeight

Function GetSkipHeight

src/chain.cpp:103–111  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

101
102/** Compute what height to jump back to with the CBlockIndex::pskip pointer. */
103int static inline GetSkipHeight(int height) {
104 if (height < 2)
105 return 0;
106
107 // Determine which height to jump back to. Any number strictly lower than height is acceptable,
108 // but the following expression seems to perform well in simulations (max 110 steps to go back
109 // up to 2**18 blocks).
110 return (height & 1) ? InvertLowestOne(InvertLowestOne(height - 1)) + 1 : InvertLowestOne(height);
111}
112
113const CBlockIndex* CBlockIndex::GetAncestor(int height) const
114{

Callers 2

GetAncestorMethod · 0.85
BuildSkipMethod · 0.85

Calls 1

InvertLowestOneFunction · 0.85

Tested by

no test coverage detected