diff options
| author | Matt Corallo <[email protected]> | 2012-08-20 21:10:25 -0400 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2013-01-16 12:48:02 -0500 |
| commit | 4c8fc1a5885634c3b463d5d44337d81cc5b1456b (patch) | |
| tree | afd148bb61784fc11a2e12bac84b46a99d887063 /src | |
| parent | Relay CMerkleBlocks when asked for MSG_FILTERED_BLOCK (diff) | |
| download | discoin-4c8fc1a5885634c3b463d5d44337d81cc5b1456b.tar.xz discoin-4c8fc1a5885634c3b463d5d44337d81cc5b1456b.zip | |
Let a node opt out of tx invs before we get a their bloom filter
Note that the default value for fRelayTxes is false, meaning we
now no longer relay tx inv messages before receiving the remote
peer's version message.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/net.cpp | 2 | ||||
| -rw-r--r-- | src/net.h | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index abb0174ed..1c1de636a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2838,6 +2838,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) vRecv >> pfrom->strSubVer; if (!vRecv.empty()) vRecv >> pfrom->nStartingHeight; + if (!vRecv.empty()) + vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message + else + pfrom->fRelayTxes = true; if (pfrom->fInbound && addrMe.IsRoutable()) { @@ -3391,6 +3395,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) delete pfrom->pfilter; pfrom->pfilter = new CBloomFilter(filter); } + pfrom->fRelayTxes = true; } @@ -3419,6 +3424,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) LOCK(pfrom->cs_filter); delete pfrom->pfilter; pfrom->pfilter = NULL; + pfrom->fRelayTxes = true; } diff --git a/src/net.cpp b/src/net.cpp index e88efcd19..319739429 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2031,6 +2031,8 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataSt LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { + if(!pnode->fRelayTxes) + continue; LOCK(pnode->cs_filter); if (pnode->pfilter) { @@ -152,6 +152,11 @@ public: bool fNetworkNode; bool fSuccessfullyConnected; bool fDisconnect; + // We use fRelayTxes for two purposes - + // a) it allows us to not relay tx invs before receiving the peer's version message + // b) the peer may tell us in their version message that we should not relay tx invs + // until they have initialized their bloom filter. + bool fRelayTxes; CSemaphoreGrant grantOutbound; CCriticalSection cs_filter; CBloomFilter* pfilter; @@ -211,6 +216,7 @@ public: nStartingHeight = -1; fGetAddr = false; nMisbehavior = 0; + fRelayTxes = false; setInventoryKnown.max_size(SendBufferSize() / 1000); pfilter = NULL; |