Add NODE_BLOOM service bit and option to disable bloom filters

This commit is contained in:
Peter Todd 2013-07-29 15:24:22 -04:00 committed by Warren Togami
parent 1877fb9aae
commit 176e54c5f7
6 changed files with 18 additions and 1 deletions

View File

@ -315,6 +315,7 @@ std::string HelpMessage()
" -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + " -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
" -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n" + " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n" +
" -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n" + " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n" +
" -bloomfilters " + _("Allow peers to set bloom filters (default: 0)") + "\n" +
#ifdef USE_UPNP #ifdef USE_UPNP
#if USE_UPNP #if USE_UPNP
" -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + " -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 // ********************************************************* Step 2: parameter interactions
fTestNet = GetBoolArg("-testnet"); fTestNet = GetBoolArg("-testnet");
fBloomFilters = GetBoolArg("-bloomfilters");
if (fBloomFilters)
nLocalServices |= NODE_BLOOM;
if (mapArgs.count("-bind")) { if (mapArgs.count("-bind")) {
// when specifying an explicit binding address, you want to listen on it // when specifying an explicit binding address, you want to listen on it

View File

@ -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") else if (strCommand == "filterload")
{ {
CBloomFilter filter; CBloomFilter filter;

View File

@ -69,6 +69,7 @@ class CMessageHeader
enum enum
{ {
NODE_NETWORK = (1 << 0), NODE_NETWORK = (1 << 0),
NODE_BLOOM = (1 << 1),
}; };
/** A CService with information about it as peer */ /** A CService with information about it as peer */

View File

@ -79,6 +79,7 @@ bool fServer = false;
bool fCommandLine = false; bool fCommandLine = false;
string strMiscWarning; string strMiscWarning;
bool fTestNet = false; bool fTestNet = false;
bool fBloomFilters = false;
bool fNoListen = false; bool fNoListen = false;
bool fLogTimestamps = false; bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0); CMedianFilter<int64> vTimeOffsets(200,0);

View File

@ -144,6 +144,7 @@ extern bool fServer;
extern bool fCommandLine; extern bool fCommandLine;
extern std::string strMiscWarning; extern std::string strMiscWarning;
extern bool fTestNet; extern bool fTestNet;
extern bool fBloomFilters;
extern bool fNoListen; extern bool fNoListen;
extern bool fLogTimestamps; extern bool fLogTimestamps;
extern volatile bool fReopenDebugLog; extern volatile bool fReopenDebugLog;

View File

@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning // 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 // earlier versions not supported as of Feb 2012, and are disconnected
static const int MIN_PROTO_VERSION = 209; static const int MIN_PROTO_VERSION = 209;