2

What's the difference between the 3 index directories I have in Bitcoin Core:

bitcoin/blocks/index/ 129 MB
bitcoin/indexes/ 59 GB
bitcoin/chainstate/ 5 GB

The size of "bitcoin/blocks/index/" is only 129 MB, with some *.ldb files inside

The size of "bitcoin/indexes" is around 59GB, which has a txindex directory with more *.ldb files in it

What's the difference between those .ldb files in the 2 directories?

The size of "chainstate" is around 5GB

As far as I understand chainstate should store the UTXO index, no? And if so, then why do we need 2 more indexing directories that are so big?

1 Answer 1

3

Bitcoin Core has multiple different databases and indexes that it maintains independently of each other since some things are optional.

blocks/index contains the LevelDB database for the block index. This contains the information of where every single block is located in the blocks/ directory (which blk*.dat file contains it, and the offset within the file). It also has the information of which rev*.dat file has the undo data, and where that undo data is within that file.

chainstate/ contains the LevelDB database that has the UTXO set.

Both the block index and the chainstate database are necessary for normal operation, and every Bitcoin Core node has them. However, they are separate as they store distinct data, and missing the chainstate database does not mean that the block index is invalid.

If you are missing the chainstate database but have the block index, the chainstate database can be rebuilt much faster than rebuilding both the chainstate and the block index. This is what the -reindex-chainstate option does - it removes the chainstate database but keeps the block index so it only has to rebuild the chainstate. -reindex is a full reindex and removes both databases.

The databasese in indexes/ are for the optional indexes - txindex, coinstatsindex, and blockfilterindex. These are maintained separately because they are not necessary for normal operation. The layout of these databases are independent of each other, and since these indexes are built asynchronously, each index has its own database.

1
  • Perfect answer! Thank you so much! Commented Jun 14 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.