aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2019-12-12 07:58:42 -0500
committerfanquake <fanquake@gmail.com>2019-12-12 08:04:31 -0500
commitcf2f4398769682cd5a0f024121a7dfd6c0aaa1ef (patch)
tree2ca00c673e153b30ddd7d64460df62a574ac543b /src
parent8a01450b642a270e69b4e0e59719179c78f9748d (diff)
parent034561f9cd4180ea1c165cb02df6c84444a8d692 (diff)
downloadbitcoin-cf2f4398769682cd5a0f024121a7dfd6c0aaa1ef.tar.xz
Merge #17687: cli: fix Fatal LevelDB error when specifying -blockfilterindex=basic twice
034561f9cd4180ea1c165cb02df6c84444a8d692 cli: fix Fatal LevelDB error when specifying -blockfilterindex=basic twice (Harris) Pull request description: This PR fixes #17679 by replacing BlockFilterType-vector with a set of the same type to make sure that only unique filter types get inserted. ACKs for top commit: MarcoFalke: ACK 034561f9cd4180ea1c165cb02df6c84444a8d692 📖 laanwj: ACK 034561f9cd4180ea1c165cb02df6c84444a8d692 fanquake: ACK 034561f9cd4180ea1c165cb02df6c84444a8d692 - Tested with `src/bitcoind --blockfilterindex=basic --blockfilterindex=basic` Tree-SHA512: 64ccec4d23528abfbb564f2b41fb846137875260ce06ea461da12175819985964a1a7442788d5ff7282b5de0c5fd46524d9a793788ee3b876626cbdf05b28c16
Diffstat (limited to 'src')
-rw-r--r--src/blockfilter.cpp8
-rw-r--r--src/blockfilter.h3
-rw-r--r--src/init.cpp6
3 files changed, 9 insertions, 8 deletions
diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp
index 787390be31..5ad22d46eb 100644
--- a/src/blockfilter.cpp
+++ b/src/blockfilter.cpp
@@ -4,6 +4,7 @@
#include <mutex>
#include <sstream>
+#include <set>
#include <blockfilter.h>
#include <crypto/siphash.h>
@@ -221,15 +222,14 @@ bool BlockFilterTypeByName(const std::string& name, BlockFilterType& filter_type
return false;
}
-const std::vector<BlockFilterType>& AllBlockFilterTypes()
+const std::set<BlockFilterType>& AllBlockFilterTypes()
{
- static std::vector<BlockFilterType> types;
+ static std::set<BlockFilterType> 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/blockfilter.h b/src/blockfilter.h
index 914b94fec1..828204b875 100644
--- a/src/blockfilter.h
+++ b/src/blockfilter.h
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <string>
+#include <set>
#include <unordered_set>
#include <vector>
@@ -97,7 +98,7 @@ const std::string& BlockFilterTypeName(BlockFilterType filter_type);
bool BlockFilterTypeByName(const std::string& name, BlockFilterType& filter_type);
/** Get a list of known filter types. */
-const std::vector<BlockFilterType>& AllBlockFilterTypes();
+const std::set<BlockFilterType>& AllBlockFilterTypes();
/** Get a comma-separated list of known filter type names. */
const std::string& ListBlockFilterTypes();
diff --git a/src/init.cpp b/src/init.cpp
index e7dda59590..9c91c93e65 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -58,6 +58,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <set>
#ifndef WIN32
#include <attributes.h>
@@ -846,7 +847,7 @@ int nUserMaxConnections;
int nFD;
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED);
int64_t peer_connect_timeout;
-std::vector<BlockFilterType> g_enabled_filter_types;
+std::set<BlockFilterType> g_enabled_filter_types;
} // namespace
@@ -934,13 +935,12 @@ bool AppInitParameterInteraction()
g_enabled_filter_types = AllBlockFilterTypes();
} else if (blockfilterindex_value != "0") {
const std::vector<std::string> 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.").translated, name));
}
- g_enabled_filter_types.push_back(filter_type);
+ g_enabled_filter_types.insert(filter_type);
}
}