diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-15 09:02:41 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-15 09:03:17 +0200 |
commit | 64e71b37210a1131de98efbbcbf2392f3e3696ac (patch) | |
tree | 6520f21433e9add20f759c6a92f608022ff33c55 | |
parent | efc059322ceffbc7485001bebc88dd2fdcb60c4d (diff) | |
parent | 66b07247a7a9e48e082502338176cc06edf61474 (diff) |
Merge #7856: Only send one GetAddr response per connection.
66b0724 Only send one GetAddr response per connection. (Gregory Maxwell)
-rw-r--r-- | src/main.cpp | 8 | ||||
-rw-r--r-- | src/net.cpp | 1 | ||||
-rw-r--r-- | src/net.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index ed9ee16545..a94d52f895 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5212,6 +5212,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } + // Only send one GetAddr response per connection to reduce resource waste + // and discourage addr stamping of INV announcements. + if (pfrom->fSentAddr) { + LogPrint("net", "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->id); + return true; + } + pfrom->fSentAddr = true; + pfrom->vAddrToSend.clear(); vector<CAddress> vAddr = addrman.GetAddr(); BOOST_FOREACH(const CAddress &addr, vAddr) diff --git a/src/net.cpp b/src/net.cpp index e64cb4ef90..f294e4c667 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2375,6 +2375,7 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa nNextAddrSend = 0; nNextInvSend = 0; fRelayTxes = false; + fSentAddr = false; pfilter = new CBloomFilter(); nPingNonceSent = 0; nPingUsecStart = 0; @@ -358,6 +358,7 @@ public: // b) the peer may tell us in its version message that we should not relay tx invs // unless it loads a bloom filter. bool fRelayTxes; + bool fSentAddr; CSemaphoreGrant grantOutbound; CCriticalSection cs_filter; CBloomFilter* pfilter; |