Skip to content

Commit 034561f

Browse files
committed
cli: fix Fatal LevelDB error when specifying -blockfilterindex=basic twice
1 parent cb11324 commit 034561f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/blockfilter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <mutex>
66
#include <sstream>
7+
#include <set>
78

89
#include <blockfilter.h>
910
#include <crypto/siphash.h>
@@ -221,15 +222,14 @@ bool BlockFilterTypeByName(const std::string& name, BlockFilterType& filter_type
221222
return false;
222223
}
223224

224-
const std::vector<BlockFilterType>& AllBlockFilterTypes()
225+
const std::set<BlockFilterType>& AllBlockFilterTypes()
225226
{
226-
static std::vector<BlockFilterType> types;
227+
static std::set<BlockFilterType> types;
227228

228229
static std::once_flag flag;
229230
std::call_once(flag, []() {
230-
types.reserve(g_filter_types.size());
231231
for (auto entry : g_filter_types) {
232-
types.push_back(entry.first);
232+
types.insert(entry.first);
233233
}
234234
});
235235

src/blockfilter.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <stdint.h>
99
#include <string>
10+
#include <set>
1011
#include <unordered_set>
1112
#include <vector>
1213

@@ -97,7 +98,7 @@ const std::string& BlockFilterTypeName(BlockFilterType filter_type);
9798
bool BlockFilterTypeByName(const std::string& name, BlockFilterType& filter_type);
9899

99100
/** Get a list of known filter types. */
100-
const std::vector<BlockFilterType>& AllBlockFilterTypes();
101+
const std::set<BlockFilterType>& AllBlockFilterTypes();
101102

102103
/** Get a comma-separated list of known filter type names. */
103104
const std::string& ListBlockFilterTypes();

src/init.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
#include <stdint.h>
6060
#include <stdio.h>
61+
#include <set>
6162

6263
#ifndef WIN32
6364
#include <attributes.h>
@@ -846,7 +847,7 @@ int nUserMaxConnections;
846847
int nFD;
847848
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED);
848849
int64_t peer_connect_timeout;
849-
std::vector<BlockFilterType> g_enabled_filter_types;
850+
std::set<BlockFilterType> g_enabled_filter_types;
850851

851852
} // namespace
852853

@@ -934,13 +935,12 @@ bool AppInitParameterInteraction()
934935
g_enabled_filter_types = AllBlockFilterTypes();
935936
} else if (blockfilterindex_value != "0") {
936937
const std::vector<std::string> names = gArgs.GetArgs("-blockfilterindex");
937-
g_enabled_filter_types.reserve(names.size());
938938
for (const auto& name : names) {
939939
BlockFilterType filter_type;
940940
if (!BlockFilterTypeByName(name, filter_type)) {
941941
return InitError(strprintf(_("Unknown -blockfilterindex value %s.").translated, name));
942942
}
943-
g_enabled_filter_types.push_back(filter_type);
943+
g_enabled_filter_types.insert(filter_type);
944944
}
945945
}
946946

0 commit comments

Comments
 (0)