kernel: Add import blocks function to C header

Add `btck_import_blocks` to import block data and rebuild indexes. The
function can either reindex all existing block files if the indexes were
previously wiped through the chainstate manager options, or import
blocks from specified file paths.
This commit is contained in:
TheCharlatan
2024-05-30 11:22:28 +02:00
parent a747ca1f51
commit 1976b13be9
4 changed files with 58 additions and 1 deletions

View File

@@ -690,6 +690,20 @@ public:
{
}
bool ImportBlocks(const std::span<const std::string> paths)
{
std::vector<const char*> c_paths;
std::vector<size_t> c_paths_lens;
c_paths.reserve(paths.size());
c_paths_lens.reserve(paths.size());
for (const auto& path : paths) {
c_paths.push_back(path.c_str());
c_paths_lens.push_back(path.length());
}
return btck_chainstate_manager_import_blocks(get(), c_paths.data(), c_paths_lens.data(), c_paths.size()) == 0;
}
bool ProcessBlock(const Block& block, bool* new_block)
{
int _new_block;