0

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 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 -reindexing the entire blockchain? Would -reindex even remove them?

1
  • There’s a negligible impact of that. Less than 1% of blocks are stale.
    – Claris
    Feb 28, 2018 at 2:27

2 Answers 2

1

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.

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

1
  • 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
    Feb 27, 2018 at 23:41

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.