I’d like to discuss a raw idea for a new feature to repair the block directory, motivated by my first IBD experience some time ago:
In case of data corruption of the chainstate, we can perform a --reindex-chainstate
.
In case of data corruption of the block index, we can perfom a --reindex
.
However, if one of the block files is corrupted, both reindex
and reindex-chainstate
will stop at some point, and we are back to IBD, which can be painful in case of a slow connection or limited traffic.
For example, in case of a bad sector in blk00002.dat
, we would download almost the entire blockchain again, even if we are actually just missing a single block on our disk.
So my idea is to create a repair-blockdir
feature that would scan the block directory (similar to reindex) and check all files for integrity and completeness using the existing block index. In case of mismatches, only the faulty blk?????.dat
files would be rebuilt, requesting specifically the missing blocks from the p2p network.
Before putting any serious work into that: Would such a feature make sense to anyone? Has something similar been attempted before?