Implement prune_gamedb RPC command. #75
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a first (trivial) "appetizer" for pruning: With this patch, a new RPC command "prune_gamedb" is implemented. This can be used to remove old entries from game.dat to shrinken it. The exact usage is like this:
huntercoind prune_gamedb DEPTH
DEPTH is the number of blocks to keep. At least the current state and one before it will always be kept, though, so it is possible to use 0 as DEPTH.
Pruning of the game state should be possible without any risk. The only consequence is that the game state has to be recalculated (expensive!) when game_getstate is used with an explicit old block number, or a reorganisation is going back beyond the last saved state (unlikely).
Doing
prune_gamedb 5000
brings the size of game.dat down from 200 MiB to less than 1 MiB. So it is not entirely pointless, although this pruning is, admittedly, the one with the least potential savings. But it was also the easiest to implement.