Add NODE_BLOOM service bit and bump protocol version

Lets nodes advertise that they offer bloom filter support explicitly.
The protocol version bump allows SPV nodes to assume that NODE_BLOOM is
set if NODE_NETWORK is set for pre-70002 nodes.

Also adds an undocumented option to turn bloom filter support off for
testing purposes. Nodes attempting to use bloom filters are immediately
dropped so as to not waste their bandwidth.
This commit is contained in:
Peter Todd 2013-10-20 22:36:31 -04:00
parent 0d09b3e8b0
commit e7a64af74f
No known key found for this signature in database
GPG key ID: 2481403DA5F091FB
6 changed files with 18 additions and 1 deletions

View file

@ -412,6 +412,11 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 2: parameter interactions
fBloomFilters = GetBoolArg("-bloomfilters", true);
if (fBloomFilters) {
nLocalServices |= NODE_BLOOM;
}
if (mapArgs.count("-bind")) {
// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified

View file

@ -3931,6 +3931,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
}
else if (!fBloomFilters &&
(strCommand == "filterload" ||
strCommand == "filteradd" ||
strCommand == "filterclear"))
{
pfrom->CloseSocketDisconnect();
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")
{

View file

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

View file

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

View file

@ -146,6 +146,7 @@ extern bool fPrintToDebugger;
extern bool fDaemon;
extern bool fServer;
extern std::string strMiscWarning;
extern bool fBloomFilters;
extern bool fNoListen;
extern bool fLogTimestamps;
extern volatile bool fReopenDebugLog;

View file

@ -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;