I would like to be able to do pruning in the kernel-node, but right now the kernel can't open a data directory that Bitcoin Core has pruned or prune its own block storage.
This separates block storage from chainstate management first and then adds pruning to the kernel API.
Commits 1 to 6 are refactors, and should not impose any behavior change. Commits 7 to 10 add a block manager and pruning to the kernel API
- Apply prune locks in BlockManager instead of in validation.
- Give BlockManager a height range and sizes to prune within, instead of letting it read the chainstate.
- Move ImportBlocks, which drives validation, out of block storage.
- Remove the friend declarations, so validation only uses BlockManager's public interface.
- Create the BlockManager first and pass it to ChainstateManager by reference. Block storage then no longer belongs to chainstate management.
- Remove ChainstateLoadOptions::prune, which duplicated BlockManager's prune mode.
- Add
btck_BlockManagerand read blocks through it. This changes the first parameter ofbtck_block_readandbtck_block_spent_outputs_read. - Add pruning up to a height and prune locks. Also lets the kernel open a data directory that Bitcoin Core has pruned.
- Add automatic pruning to a target size.
- Add
btck_chainstate_manager_get_first_available_entry