1

From source code:

/** The block chain is a tree shaped structure starting with the
 * genesis block at the root, with each block potentially having multiple
 * candidates to be the next block. A blockindex may have multiple pprev pointing
 * to it, but at most one of them can be part of the currently active branch.
 */
class CBlockIndex




//! pointer to the index of the predecessor of this block
CBlockIndex* pprev;

//! pointer to the index of some further predecessor of this block
CBlockIndex* pskip;

Can anyone help me understand the need for skip pointers, perhaps with a picture? Why should we track this? The comment says some predecessor . When and where are these useful?

2

It is implenting a skiplist.

Every index node points to its immediate predecessor (pprev), and to some other predecessor that is further away (pskip). These skip pointers are used when we need to find a far predecessor quickly. One common case is when we need to find the 2016th ancestor of a block to recompute the target difficulty.

Most of the skip pointers only go back a few blocks, but ocassionally one points back very far, allowing many nodes to be skipped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.