I see block chain is stored basically four pieces of data that are maintained:
- blocks/blk*.dat:
the actual Bitcoin blocks, in network format, dumped in raw on disk. They are only needed for rescanning missing transactions in a wallet, reorganizing to a different part of the chain, and serving the block data to other nodes that are synchronizing.
- blocks/index/*:
this is a LevelDB database that contains metadata about all known blocks, and where to find them on disk. Without this, finding a block would be very slow.
- chainstate/*:
this is a LevelDB database with a compact representation of all currently unspent transaction outputs and some metadata about the transactions they are from.
- blocks/rev*.dat:
these contain "undo" data. You can see blocks as 'patches' to the chain state (they consume some unspent outputs, and produce new ones), and see the undo data as reverse patches. They are necessary for rolling back the chainstate, which is necessary in case of reorganisations.
But I still don't understand how rev*.dat work. Can somebody explain in detail how to use them?