mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
kernel: Add chainstate load options for in-memory dbs in C header
This allows a user to run the kernel without creating on-disk files for the block tree and chainstate indexes. This is potentially useful in scenarios where the user needs to do some ephemeral validation operations. One specific use case is when linearizing the blocks on disk. The block files store blocks out of order, so a program may utilize the library and its header to read the blocks with one chainstate manager, and then write them back in order, and without orphans, with another chainstate maanger. To save disk resources and if the indexes are not required once done, it may be beneficial to keep the indexes in memory for the chainstate manager that writes the blocks back again.
This commit is contained in:
@@ -719,6 +719,24 @@ int btck_chainstate_manager_options_set_wipe_dbs(btck_ChainstateManagerOptions*
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btck_chainstate_manager_options_update_block_tree_db_in_memory(
|
||||
btck_ChainstateManagerOptions* chainman_opts,
|
||||
int block_tree_db_in_memory)
|
||||
{
|
||||
auto& opts{btck_ChainstateManagerOptions::get(chainman_opts)};
|
||||
LOCK(opts.m_mutex);
|
||||
opts.m_blockman_options.block_tree_db_params.memory_only = block_tree_db_in_memory == 1;
|
||||
}
|
||||
|
||||
void btck_chainstate_manager_options_update_chainstate_db_in_memory(
|
||||
btck_ChainstateManagerOptions* chainman_opts,
|
||||
int chainstate_db_in_memory)
|
||||
{
|
||||
auto& opts{btck_ChainstateManagerOptions::get(chainman_opts)};
|
||||
LOCK(opts.m_mutex);
|
||||
opts.m_chainstate_load_options.coins_db_in_memory = chainstate_db_in_memory == 1;
|
||||
}
|
||||
|
||||
btck_ChainstateManager* btck_chainstate_manager_create(
|
||||
const btck_ChainstateManagerOptions* chainman_opts)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user