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
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 thepruneblockchain
rpcprune=<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
-
4And to be clear: no, you can't just delete the files manually. Bitcoin Core will notice the files are missing and abort. Feb 23 at 15:01