Permalink
Browse files

Merge #7856: Only send one GetAddr response per connection.

66b0724 Only send one GetAddr response per connection. (Gregory Maxwell)
  • Loading branch information...
laanwj committed Apr 15, 2016
2 parents efc0593 + 66b0724 commit 64e71b37210a1131de98efbbcbf2392f3e3696ac
Showing with 10 additions and 0 deletions.
  1. +8 −0 src/main.cpp
  2. +1 −0 src/net.cpp
  3. +1 −0 src/net.h
View
@@ -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)
View
@@ -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;
View
@@ -358,6 +358,7 @@ class CNode
// 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;

0 comments on commit 64e71b3

Please sign in to comment.