mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 08:13:52 +02:00
index: Access functions for global block filter indexes.
This commit is contained in:
@@ -94,6 +94,8 @@ struct DBHashKey {
|
||||
|
||||
}; // namespace
|
||||
|
||||
static std::map<BlockFilterType, BlockFilterIndex> g_filter_indexes;
|
||||
|
||||
BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
|
||||
size_t n_cache_size, bool f_memory, bool f_wipe)
|
||||
: m_filter_type(filter_type)
|
||||
@@ -432,3 +434,34 @@ bool BlockFilterIndex::LookupFilterHashRange(int start_height, const CBlockIndex
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockFilterIndex* GetBlockFilterIndex(BlockFilterType filter_type)
|
||||
{
|
||||
auto it = g_filter_indexes.find(filter_type);
|
||||
return it != g_filter_indexes.end() ? &it->second : nullptr;
|
||||
}
|
||||
|
||||
void ForEachBlockFilterIndex(std::function<void (BlockFilterIndex&)> fn)
|
||||
{
|
||||
for (auto& entry : g_filter_indexes) fn(entry.second);
|
||||
}
|
||||
|
||||
bool InitBlockFilterIndex(BlockFilterType filter_type,
|
||||
size_t n_cache_size, bool f_memory, bool f_wipe)
|
||||
{
|
||||
auto result = g_filter_indexes.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(filter_type),
|
||||
std::forward_as_tuple(filter_type,
|
||||
n_cache_size, f_memory, f_wipe));
|
||||
return result.second;
|
||||
}
|
||||
|
||||
bool DestroyBlockFilterIndex(BlockFilterType filter_type)
|
||||
{
|
||||
return g_filter_indexes.erase(filter_type);
|
||||
}
|
||||
|
||||
void DestroyAllBlockFilterIndexes()
|
||||
{
|
||||
g_filter_indexes.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user