<p>It is implenting a skiplist.</p>

<p>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.</p>

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

CC BY-SA 3.0
2016-01-05T05:34:02.817Z
2016-01-05T20:03:26.227Z
2016-01-05T20:03:26.227Z
Pieter Wuille
<p>From source code:</p>

<pre><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;
</code></pre>

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

<blockchain><bitcoind><bitcoin-core><consensus>
Understanding skip pointers in BlockIndex in bitcoin sources
Guhan S
# Understanding skip pointers in BlockIndex in bitcoin sources

(Asked by: username_0 on 2016-01-05)

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?

**Tags:** blockchain, bitcoind, bitcoin-core, consensus


---

## 1 answers

### Answer by username_1 on 2016-01-05. Score: 4 | Accepted answer

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.


---

