Can you prune block data from a specific date range in Bitcoin Core?

4 replies 192 views
gwei_minerSenior Member
Posts: 197 · Reputation: 966
#1Feb 24, 2022, 04:56 AM
I've been running a Bitcoin Core node and got into the whole pruning thing. Since I don’t have an external SSD and my space is limited, I figured out how Prune mode works. But it seems like it only keeps the most recent block data and tosses the old stuff when new blocks come in. Why can't we prune block data for a specific date range? Like, if I want to keep two years' worth of block data, why can't I just choose to keep blocks from that specific time frame in my Bitcoin Core directory? I haven't found a way to make that work.
2 Reply Quote Share
cryptobridgeSenior Member
Posts: 221 · Reputation: 1481
#2Feb 24, 2022, 05:09 AM
Pruning was never about specific date, it's about disk space you are willing to keep for blocks on your computer. If you are willing to make space of 2gb, put the number on your configuration, core will do the rest. If you want to know blocks of specific date, you have to do the math's. Knows blocks produced each day and do the calculations. You can play around with https://ycharts.com/indicators/bitcoin_blockchain_size It shows total blocks produce in GBs, saw an estimate of 705gb for yesterday update, that means today has not been updated till later time. Just so you know, recent block years are heavy than the early blocks, you will need big space on your computer.
1 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#3Feb 24, 2022, 10:00 AM
Since you asked why, I'll answer with: because it's not yet implemented to prune option or as a new "prune by timestamp" option. But it's not impossible to implement if it's necessary. For the current version of the reference client, the closest feature that you can utilize is "manual pruning". Setting "prune=1" in your config or adding --prune as a command line arg will enable that. With that enabled, you can use pruneblockchain command which supports epoch timestamp as arg. (set it to a date 2 years ago) But you'll have to do it periodically since it's manual. Here's the documentation of that command: bitcoincore.org/en/doc/30.0.0/rpc/blockchain/pruneblockchain
2 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#4Feb 24, 2022, 02:30 PM
Good idea. If it's combined with bash script and system service, the prune process also can be automated. Just make sure date and time on your system is properly synced.
2 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#5Feb 24, 2022, 04:12 PM
Maybe Bitcoin block data (1013 GB): inputs, outputs and transactions has what you're looking for. You could prune Bitcoin Core to 200 GB, and take it offline after it reaches the year you need.
6 Reply Quote Share

Related topics