18 vChain.resize(pindex->
nHeight + 1);
19 while (pindex && vChain[pindex->
nHeight] != pindex) {
20 vChain[pindex->
nHeight] = pindex;
21 pindex = pindex->
pprev;
27 std::vector<uint256> vHave;
38 int nHeight = std::max(pindex->
nHeight - nStep, 0);
39 if (Contains(pindex)) {
41 pindex = (*this)[nHeight];
46 if (vHave.size() > 10)
59 while (pindex && !Contains(pindex))
60 pindex = pindex->
pprev;
80 if (height > nHeight || height < 0)
84 int heightWalk = nHeight;
85 while (heightWalk > height) {
88 if (pindexWalk->
pskip != NULL &&
89 (heightSkip == height ||
90 (heightSkip > height && !(heightSkipPrev < heightSkip - 2 &&
91 heightSkipPrev >= height)))) {
93 pindexWalk = pindexWalk->
pskip;
94 heightWalk = heightSkip;
96 assert(pindexWalk->
pprev);
97 pindexWalk = pindexWalk->
pprev;
106 return const_cast<CBlockIndex*
>(
this)->GetAncestor(height);
void SetTip(CBlockIndex *pindex)
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
static int InvertLowestOne(int n)
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
uint256 GetBlockHash() const
static int GetSkipHeight(int height)
CBlockIndex * pprev
pointer to the index of the predecessor of this block
CBlockLocator GetLocator(const CBlockIndex *pindex=NULL) const
void BuildSkip()
Build the skiplist pointer for this entry.
int nHeight
height of the entry in the chain. The genesis block has height 0