From 176e54c5f70f65c7b9c16fe69e49af538aec688d Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Mon, 29 Jul 2013 15:24:22 -0400 Subject: [PATCH] Add NODE_BLOOM service bit and option to disable bloom filters --- src/init.cpp | 4 ++++ src/main.cpp | 10 ++++++++++ src/protocol.h | 1 + src/util.cpp | 1 + src/util.h | 1 + src/version.h | 2 +- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 2145d29fea..5ae4a80ebf 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -315,6 +315,7 @@ std::string HelpMessage() " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n" + " -maxsendbuffer= " + _("Maximum per-connection send buffer, *1000 bytes (default: 1000)") + "\n" + + " -bloomfilters " + _("Allow peers to set bloom filters (default: 0)") + "\n" + #ifdef USE_UPNP #if USE_UPNP " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + @@ -494,6 +495,9 @@ bool AppInit2(boost::thread_group& threadGroup) // ********************************************************* Step 2: parameter interactions fTestNet = GetBoolArg("-testnet"); + fBloomFilters = GetBoolArg("-bloomfilters"); + if (fBloomFilters) + nLocalServices |= NODE_BLOOM; if (mapArgs.count("-bind")) { // when specifying an explicit binding address, you want to listen on it diff --git a/src/main.cpp b/src/main.cpp index 17f94b8575..5f01875ce3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3692,6 +3692,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } + else if (!fBloomFilters && + (strCommand == "filterload" || + strCommand == "filteradd" || + strCommand == "filterclear")) + { + pfrom->Misbehaving(100); + return error("peer %s attempted to set a bloom filter even though we do not advertise that service", + pfrom->addr.ToString().c_str()); + } + else if (strCommand == "filterload") { CBloomFilter filter; diff --git a/src/protocol.h b/src/protocol.h index 35cf156d64..a6726dd340 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -69,6 +69,7 @@ class CMessageHeader enum { NODE_NETWORK = (1 << 0), + NODE_BLOOM = (1 << 1), }; /** A CService with information about it as peer */ diff --git a/src/util.cpp b/src/util.cpp index d72a566e7d..321bd25b94 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -79,6 +79,7 @@ bool fServer = false; bool fCommandLine = false; string strMiscWarning; bool fTestNet = false; +bool fBloomFilters = false; bool fNoListen = false; bool fLogTimestamps = false; CMedianFilter vTimeOffsets(200,0); diff --git a/src/util.h b/src/util.h index 2be01e19f8..130933d1f3 100644 --- a/src/util.h +++ b/src/util.h @@ -144,6 +144,7 @@ extern bool fServer; extern bool fCommandLine; extern std::string strMiscWarning; extern bool fTestNet; +extern bool fBloomFilters; extern bool fNoListen; extern bool fLogTimestamps; extern volatile bool fReopenDebugLog; diff --git a/src/version.h b/src/version.h index f1e7c4cd7b..281159b978 100644 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70001; +static const int PROTOCOL_VERSION = 70002; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 209;