<p>They're kept because it is complicated to remove them (it would require rewriting the block storage files), and there is hardly any cost to keeping them (they're a small fraction of the total). Furthermore, close to the tip we <em>want</em> to have forks available, in order to be able to reorganize quickly if one of them ends up becoming the main chain.</p>

<p>More technically, the $DATADIR/blocks directory for Bitcoin Core is not a representation of the blockchain. It's a store of all valid blocks we've ever downloaded. Which out of them end up being considered the main chain is a different issue, and dealt with independently.</p>

<p>Also note that in pruning mode all old blocks are removed - including these small forks.</p>

CC BY-SA 4.0
2018-05-05T20:46:58.797Z
2018-05-05T20:46:58.797Z
Pieter Wuille
<p>I cannot think of any convenient way to do this.</p>

<p>The only method that comes to mind is to create for yourself a <a href="https://bitcoin.stackexchange.com/a/42916/75001"><code>bootstrap.dat</code></a> file from your own up to date node, then exit Bitcoin Core and manually clear out all the relevant db files before importing from the <code>bootstrap.dat</code>.</p>

CC BY-SA 3.0
2018-02-27T23:41:11.837Z
Are these small forks called "orphans"? How come they only seem to appear when you've been actually running a node? Is it because node's don't rebroadcast orphaned blocks, but do save them indefinitely?
Brannon
CC BY-SA 3.0
2018-02-27T20:53:02.833Z
2018-02-27T20:53:02.833Z
Willtech
<p>I've noticed that <code>bitcoind</code> will permanently save unverified blocks that it receives even if they turn out to be small blockchain forks, likely occurring from the relatively simultaneous discovery of two blocks of equal height. This doesn't cause a problem for Bitcoin Core's functionality, as there is surely a process written into the source that ignores such small forks, however, it's curious to me that the data persists in <a href="https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage" rel="nofollow noreferrer">the data saved to the <code>.dat</code> and <code>.ldb</code> files</a> in <code>.bitcoin/blocks/</code> and <code>.bitcoin/blocks/index</code> nonetheless. Is there a way to prune these invalid blocks that belong to small forks in the blockchain without <code>-reindex</code>ing the entire blockchain? Would <code>-reindex</code> even remove them?</p>

CC BY-SA 3.0
2018-02-28T02:27:00.610Z
There’s a negligible impact of that. Less than 1% of blocks are stale.
Claris
<bitcoin-core><bitcoind><client><block><verification>
Bitcoin Core LevelDB Index saves forked blocks
Brannon
# Bitcoin Core LevelDB Index saves forked blocks

(Asked by: username_0 on 2018-02-27)

I've noticed that `bitcoind` will permanently save unverified blocks that it receives even if they turn out to be small blockchain forks, likely occurring from the relatively simultaneous discovery of two blocks of equal height. This doesn't cause a problem for Bitcoin Core's functionality, as there is surely a process written into the source that ignores such small forks, however, it's curious to me that the data persists in [the data saved to the `.dat` and `.ldb` files](https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage) in `.bitcoin/blocks/` and `.bitcoin/blocks/index` nonetheless. Is there a way to prune these invalid blocks that belong to small forks in the blockchain without `-reindex`ing the entire blockchain? Would `-reindex` even remove them?

**Tags:** bitcoin-core, bitcoind, client, block, verification

> **Comments:**
> **username_1**: There’s a negligible impact of that. Less than 1% of blocks are stale.  

---

## 2 answers

### Answer by username_2 on 2018-05-05. Score: 1 | Accepted answer

They're kept because it is complicated to remove them (it would require rewriting the block storage files), and there is hardly any cost to keeping them (they're a small fraction of the total). Furthermore, close to the tip we *want* to have forks available, in order to be able to reorganize quickly if one of them ends up becoming the main chain.

More technically, the $DATADIR/blocks directory for Bitcoin Core is not a representation of the blockchain. It's a store of all valid blocks we've ever downloaded. Which out of them end up being considered the main chain is a different issue, and dealt with independently.

Also note that in pruning mode all old blocks are removed - including these small forks.


---

### Answer by username_3 on 2018-02-27. Score: 0

I cannot think of any convenient way to do this.

The only method that comes to mind is to create for yourself a [`bootstrap.dat`](https://bitcoin.stackexchange.com/a/42916/75001) file from your own up to date node, then exit Bitcoin Core and manually clear out all the relevant db files before importing from the `bootstrap.dat`.

> **Comments:**
> **username_0**: Are these small forks called "orphans"? How come they only seem to appear when you've been actually running a node? Is it because node's don't rebroadcast orphaned blocks, but do save them indefinitely?  

---

