45

What is the difference between the options -reindex and -reindex-chainstate?

Is one of the options faster?

When should each option be used?

2 Answers 2

64

-reindex:

  • wipes the chainstate (the UTXO set)
  • wipes the block index (the database with information about which block is where on disk)
  • rebuilds the block index (by going over all blk*.dat files, and finding things in it that look like blocks)
  • rebuilds the chainstate (redoing all validation for blocks) based on the blocks now in the index

-reindex-chainstate:

  • wipes the chainstate
  • rebuilds the chainstate using the blocks in the index you had before

The latter should be strictly faster, as it does not need to rebuild the block index first. Perhaps the progress bar during reindex confuses you: that progress is only for the rebuilding of the index. The recreation of the chainstate happens after that rebuild is completed.

You should use -reindex only when you were running in pruning mode, or if you suspect the blocks on disk are actually corrupted. Otherwise, when you only suspect corruption of the chainstate (which is far more likely), use -reindex-chainstate.

5
  • 1
    Thank you for your answer, I am actually running the node on a headless server, so I do not see a progress bar. Is there a definitive way to know when the sync is complete? I am currently doing it by looking at the log and seeing when the time stamp of the blocks catches up to the present.
    – amanusk
    Commented Oct 19, 2017 at 6:07
  • For progress on a headless machine (no gui), I watched the bitcoind log. There were many UpdateTip messages that showed the block height. For example: height=201202. Indeed the progress goes faster when the node already has the blk*.dat files than having to re-download the blocks
    – Donn Lee
    Commented Feb 28, 2021 at 7:43
  • 1
    is there any other command that are in between these two? I'm having issues on a server where I keep getting corrupt 1 or 2 files. Is it not possible to only fix these specific .blk or .ldb files e.g. Fatal LevelDB error: IO error: /root/.bitcoin/chainstate/000184.ldb: Bad message
    – pseudozach
    Commented Sep 28, 2021 at 18:26
  • 2
    Both -reindex and -reindex-chainstate throw away all chainstate/*.ldb files and rebuilds them. If you're seeing this error after a -reindex, most likely you have a hardware problem. Commented Sep 28, 2021 at 18:27
  • Note on a pruned node, -reindex nukes all your blockchain data. I had 10GB on a prune=550 node and it blew it all away. It then proceeded to download everything from 2009 onward. This is insane when the point of a pruned node is to avoid all the intense, long lasting work. I had a blockchain data backup and github blockchain downloads are also a good backup but there's some thing really wrong with how pruned nodes and wallets work.
    – Shovas
    Commented Feb 12 at 9:28
0

if you using reindex-chainstate is more faster . also i have collection script to monitor block status block monitor example script

you can ruuning with crontab and see how many block have been sync and compare with mainnet block excplorer.

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.