Post
Topic
Board Development & Technical Discussion
Re: How to manually verify blk*.dat and rev*.dat files?
by
almightyruler
on 23/02/2019, 15:05:54 UTC

How about my other question? I am sorry for a basic question as I didn't realise that until now.

What will happen if my main full node (which has all blocks from blk00000.dat) fails to send valid data to its peers due to corrupted (for whatever reasons) blk*.dat and/or rev*.dat files? What kind of mechanism applies in bitcoind?

It's my understanding that the blk*.dat files are append only, so everything but the current file is 100% immutable. (Until I started pruning on my oldest Bitcoin node, my low numbered blk*.dat files had a last-modified timestamp from 2011.) If this is correct, there's no need to repeatedly verify the entire blockchain with exhaustive checks, since the data in the large majority of the dat files will never be updated by the client. Something like this should suffice:

1. A byte level checksum of all blk*.dat and rev*.dat files except the current file to confirm that previously verified data has not changed;
2. A complete verification of individual blocks and transactions in the current blk*.dat file (-checkblocks=x at startup, or the verifychain RPC call)

The value of x would need to be generous in order to ensure it covers the final block file. (Would be handy if there was a way to specify the height, blockhash, or blk*.dat file to start at.)

Back in 2013 it seems the client checked the last 2500 blocks by default! https://bitcointalk.org/index.php?topic=141200.0