diff --git a/src/init.cpp b/src/init.cpp index 76e6f35dc..730b0f75f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1025,6 +1025,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Option to startup with mocktime set (used for regression testing): SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op + if (GetBoolArg("-peerbloomfilters", true)) + nLocalServices |= NODE_BLOOM; + #ifdef ENABLE_MINING if (mapArgs.count("-mineraddress")) { CBitcoinAddress addr; diff --git a/src/main.cpp b/src/main.cpp index e1b49a62b..1848ee7fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5498,6 +5498,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } + else if (!(nLocalServices & NODE_BLOOM) && + (strCommand == "filterload" || + strCommand == "filteradd" || + strCommand == "filterclear") && + //TODO: Remove this line after reasonable network upgrade + pfrom->nVersion >= NO_BLOOM_VERSION) + { + if (pfrom->nVersion >= NO_BLOOM_VERSION) + Misbehaving(pfrom->GetId(), 100); + //TODO: Enable this after reasonable network upgrade + //else + // pfrom->fDisconnect = true; + } + + else if (strCommand == "filterload") { CBloomFilter filter; diff --git a/src/protocol.h b/src/protocol.h index b0208b01c..5eafb7df6 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -71,6 +71,10 @@ enum { // set by all Bitcoin Core nodes, and is unset by SPV clients or other peers that just want // network services but don't provide them. NODE_NETWORK = (1 << 0), + // NODE_BLOOM means the node is capable and willing to handle bloom-filtered connections. + // Zcash nodes used to support this by default, without advertising this bit, + // but no longer do as of protocol version 170004 (= NO_BLOOM_VERSION) + NODE_BLOOM = (1 << 2), // Bits 24-31 are reserved for temporary experiments. Just pick a bit that // isn't getting used, or one not being used much, and notify the diff --git a/src/version.h b/src/version.h index 25527895d..258534aa6 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170003; +static const int PROTOCOL_VERSION = 170004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -30,4 +30,7 @@ static const int BIP0031_VERSION = 60000; //! "mempool" command, enhanced "getdata" behavior starts with this version static const int MEMPOOL_GD_VERSION = 60002; +//! "filter*" commands are disabled without NODE_BLOOM after and including this version +static const int NO_BLOOM_VERSION = 170004; + #endif // BITCOIN_VERSION_H