diff --git a/src/blockfilter.h b/src/blockfilter.h --- a/src/blockfilter.h +++ b/src/blockfilter.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -98,7 +99,7 @@ BlockFilterType &filter_type); /** Get a list of known filter types. */ -const std::vector &AllBlockFilterTypes(); +const std::set &AllBlockFilterTypes(); /** Get a comma-separated list of known filter type names. */ const std::string &ListBlockFilterTypes(); diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -219,14 +219,13 @@ return false; } -const std::vector &AllBlockFilterTypes() { - static std::vector types; +const std::set &AllBlockFilterTypes() { + static std::set types; static std::once_flag flag; std::call_once(flag, []() { - types.reserve(g_filter_types.size()); for (auto entry : g_filter_types) { - types.push_back(entry.first); + types.insert(entry.first); } }); diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -82,6 +82,7 @@ #endif #include #include +#include static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_REST_ENABLE = false; @@ -1572,7 +1573,7 @@ int nFD; ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED); int64_t peer_connect_timeout; -std::vector g_enabled_filter_types; +std::set g_enabled_filter_types; } // namespace @@ -1667,14 +1668,13 @@ } else if (blockfilterindex_value != "0") { const std::vector names = gArgs.GetArgs("-blockfilterindex"); - g_enabled_filter_types.reserve(names.size()); for (const auto &name : names) { BlockFilterType filter_type; if (!BlockFilterTypeByName(name, filter_type)) { return InitError( strprintf(_("Unknown -blockfilterindex value %s."), name)); } - g_enabled_filter_types.push_back(filter_type); + g_enabled_filter_types.insert(filter_type); } }