5

Since bitcoin validates blockchain by the hash of older blocks recursively; Can I just keep the last blk*.dat file and delete the rest while the bitcoin core is downloading and validating the blockchain?

1 Answer 1

10

No, if you manually delete these files, Bitcoin Core will notice the missing files and abort.

However, Bitcoin Core does have functionality to discard blocks after validating them: pruning. You can enable pruning by setting prune=<n> in your bitcoin.conf file or by passing -prune=<n> to bitcoind on startup.

Check bitcoind -h for more information, but briefly:

  • prune=1 allows for manually deleting blocks using the pruneblockchain rpc
  • prune=<some number >= 550> enables your node to automatically delete blocks to keep the size, measured in MiB, less than the number specified

A few things to keep in mind when pruning:

  • You cannot run txindex while pruning, so you won't be able to use your node to lookup specific transactions
  • If you ever want to turn pruning off, you will need to re-download the entire blockchain
1
  • 4
    And to be clear: no, you can't just delete the files manually. Bitcoin Core will notice the files are missing and abort. Commented Feb 23, 2023 at 15:01

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.