diff options
author | Jim Posen <jim.posen@gmail.com> | 2018-08-30 08:30:23 -0700 |
---|---|---|
committer | Jim Posen <jim.posen@gmail.com> | 2019-04-06 12:10:55 -0700 |
commit | accc8b8b1842ed6d522b71a056777bcac8f39e81 (patch) | |
tree | a94aec9035ccd602835e18997f6f19b116f5dc1b /src/index/blockfilterindex.cpp | |
parent | 2bc90e4e7bf7fef56830b33b1fba678fd0dbd6d8 (diff) | |
download | bitcoin-accc8b8b1842ed6d522b71a056777bcac8f39e81.tar.xz |
index: Access functions for global block filter indexes.
Diffstat (limited to 'src/index/blockfilterindex.cpp')
-rw-r--r-- | src/index/blockfilterindex.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index a55aeca704..20f33baf2c 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -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(); +} |