kernel: Add options for reindexing in C header

Adds options for wiping the chainstate and block tree indexes to the
chainstate manager options. In combination and once the
`*_import_blocks(...)` function is added in a later commit, this
triggers a reindex. For now, it just wipes the existing data.
This commit is contained in:
TheCharlatan
2024-06-17 22:50:47 +02:00
parent ad80abc73d
commit 070e77732c
4 changed files with 71 additions and 6 deletions

View File

@@ -706,6 +706,19 @@ void btck_chainstate_manager_options_destroy(btck_ChainstateManagerOptions* opti
delete options;
}
int btck_chainstate_manager_options_set_wipe_dbs(btck_ChainstateManagerOptions* chainman_opts, int wipe_block_tree_db, int wipe_chainstate_db)
{
if (wipe_block_tree_db == 1 && wipe_chainstate_db != 1) {
LogError("Wiping the block tree db without also wiping the chainstate db is currently unsupported.");
return -1;
}
auto& opts{btck_ChainstateManagerOptions::get(chainman_opts)};
LOCK(opts.m_mutex);
opts.m_blockman_options.block_tree_db_params.wipe_data = wipe_block_tree_db == 1;
opts.m_chainstate_load_options.wipe_chainstate_db = wipe_chainstate_db == 1;
return 0;
}
btck_ChainstateManager* btck_chainstate_manager_create(
const btck_ChainstateManagerOptions* chainman_opts)
{