The kernel creates its block storage inside btck_chainstate_manager_create, configures it through the chainstate manager's options and reads blocks through the chainstate manager. Pruning (#35627) needs block storage that the caller can configure, keep and prune directly.
This adds btck_BlockManagerOptions and btck_BlockManager. btck_chainstate_manager_create takes a block manager and keeps a shared reference to it, so either handle can be destroyed first. A block manager can be passed to only one chainstate manager, and a failed creation still uses it up unless the contexts differ. btck_block_read and btck_block_spent_outputs_read take the block manager, and block tree entries are valid for its lifetime, which can be longer than the chainstate manager's.
Changes for callers:
btck_chainstate_manager_options_createno longer takes a blocks directory.btck_chainstate_manager_options_set_wipe_dbsis replaced bybtck_block_manager_options_update_wipe_block_tree_dbandbtck_chainstate_manager_options_update_wipe_chainstate_db. The block tree db is wiped when the block manager is created, and wiping it also wipes the chainstate db, which the old function required anyway.btck_chainstate_manager_options_update_block_tree_db_in_memorymoves to the block manager options.- Both options objects take the same total database cache, and each uses its own share.
Based on #36739. Draft until it is merged. Feedback on the API is welcome in the meantime.