<p>Block heights on the "valid blockchain" are sequential, but a block that is produced might become reorganized out of the blockchain (as a result of a soft fork in the network). This <em>does</em> happen occasionally and isn't anything to be concerned most of the time.</p>

<p>Those blocks that are reorganized out of the blockchain still have a height, but that is still in sequence from its predecessor, but the block on the main blockchain will also have that height. It is possible that your blkXXXXX.dat contain a few blocks that are not on the blockchain.</p>

<pre><code>Genesis block(0) --&gt; 1 --&gt; 2  --&gt; 3 Main Chain
                       \-- 2 (reorged out)
</code></pre>

CC BY-SA 3.0
2014-04-04T19:15:44.747Z
2014-04-04T19:15:44.747Z
njaard
<p>Block height is by definition sequential in the sense that adjacent blocks will always have heights that differ by 1.  But there is a chicken-and-egg problem: in order to compute the height, you have to have access to all the blocks in between the genesis block and the current one.  (The height is not recorded in the block itself.)</p>

<p>There's also the issue that multiple blocks can have the same height, if they are on different branches of the chain.  So just because you have one block at every height, doesn't mean you have all the blocks on the main chain; some of them might be on orphan branches.</p>

CC BY-SA 3.0
2014-04-04T16:34:06.150Z
2014-04-04T16:34:06.150Z
Nate Eldredge
<p>Is block height always sequential? Can it serve as a 100% reliable block counter in case if I want to check whether I missed a block or I need to account for any corner cases?</p>

<blockchain><height>
Is block height always sequential?
Alexey Kalmykov
# Is block height always sequential?

(Asked by: username_0 on 2014-04-04)

Is block height always sequential? Can it serve as a 100% reliable block counter in case if I want to check whether I missed a block or I need to account for any corner cases?

**Tags:** blockchain, height


---

## 2 answers

### Answer by username_2 on 2014-04-04. Score: 6 | Accepted answer

Block height is by definition sequential in the sense that adjacent blocks will always have heights that differ by 1. But there is a chicken-and-egg problem: in order to compute the height, you have to have access to all the blocks in between the genesis block and the current one. (The height is not recorded in the block itself.)

There's also the issue that multiple blocks can have the same height, if they are on different branches of the chain. So just because you have one block at every height, doesn't mean you have all the blocks on the main chain; some of them might be on orphan branches.


---

### Answer by username_1 on 2014-04-04. Score: 3

Block heights on the "valid blockchain" are sequential, but a block that is produced might become reorganized out of the blockchain (as a result of a soft fork in the network). This does happen occasionally and isn't anything to be concerned most of the time.
Those blocks that are reorganized out of the blockchain still have a height, but that is still in sequence from its predecessor, but the block on the main blockchain will also have that height. It is possible that your blkXXXXX.dat contain a few blocks that are not on the blockchain.
Genesis block(0) --> 1 --> 2  --> 3 Main Chain
                       \-- 2 (reorged out)


---

