Do I need to keep all blocks, from block 0 up to the current one, when running Bitcoin Core, either as a full node or not? Or can I just keep the more recent blocks to save space?
2 Answers
Full nodes keep all blocks by default, but this is not necessary to achieve full node security. Full nodes validate the complete blockchain and enforce all consensus rules regardless of whether a full history is kept.
Keeping all blocks is a service to the network, as you'll be able to provide all blocks for synchronizing nodes or requests of thin clients.
If keeping the full blockchain is a problem, you can reduce the storage-footprint by running Bitcoin Core in pruning mode. Just add prune=<n>
to your bitcoin.conf
, where <n>
is the amount of youngest blocks you want to keep in terms of mebibytes storage. The minimum is 550 MiB.
-
1@Geremia: You need to turn on pruning and let Core sort it out. Otherwise, Core will discover that there are files missing.– Murch ♦Sep 23, 2016 at 19:37
-
2Yes. The chain-state database and UTXO set are kept intact and completely. As Core has validated the full blockchain, it knows about the old transactions and stores the relevant UTXO data. It will also keep all information related to its own addresses.– Murch ♦Sep 23, 2016 at 19:38
-
3I don't get what you're asking. If you want to reduce the storage-footprint, just start with pruning mode. You'll still need the blocks directory, as you'll keep at least 550 MiB. I haven't tried, but I'd expect Core to start redownloading all blocks if you just delete the directory manually.– Murch ♦Sep 24, 2016 at 7:40
-
2"I haven't tried, but I'd expect Core to start redownloading all blocks if you just delete the directory manually." Yes, that's what happened when I tried it.– GeremiaSep 25, 2016 at 6:00
-
2
This is called pruning.
From here:
Since Bitcoin-Core 0.11.0 you can prune (trim) the blockchain in Bitcoin-Qt. But not from the UI. You need to add
-prune=550
to your bitcoin.conf file and restart Bitcoin-Qt.Explanation:
-prune=<target in MiB>
will tell bitcoin-core to remove blocks which are older than oldest block that can be kept with a chainsize (sum of block-sizes) of<target>
(min. 550MiB as example above shows). A minimum of 550MiB ensures to keep at least 288 blocks (~2 days). (simple explanation not including undo-data)Restriction:
-prune
does disable all wallet functions in version 0.11 (will work with a wallet in version 0.12).
Obviously, as a full node you can't serve historical blocks you don't have, so you're more like a P2P leecher.