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

Function GetSkipHeight

src/chain.cpp:72–80  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

70
71/** Compute what height to jump back to with the CBlockIndex::pskip pointer. */
72int static inline GetSkipHeight(int height) {
73 if (height < 2)
74 return 0;
75
76 // Determine which height to jump back to. Any number strictly lower than height is acceptable,
77 // but the following expression seems to perform well in simulations (max 110 steps to go back
78 // up to 2**18 blocks).
79 return (height & 1) ? InvertLowestOne(InvertLowestOne(height - 1)) + 1 : InvertLowestOne(height);
80}
81
82const CBlockIndex* CBlockIndex::GetAncestor(int height) const
83{

Callers 2

GetAncestorMethod · 0.85
BuildSkipMethod · 0.85

Calls 1

InvertLowestOneFunction · 0.85

Tested by

no test coverage detected