Browse Source

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

66b0724 Only send one GetAddr response per connection. (Gregory Maxwell)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
64e71b3721
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 8
      src/main.cpp
  2. 1
      src/net.cpp
  3. 1
      src/net.h

8
src/main.cpp

@ -5212,6 +5212,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, @@ -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)

1
src/net.cpp

@ -2375,6 +2375,7 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa @@ -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;

1
src/net.h

@ -358,6 +358,7 @@ public: @@ -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;

Loading…
Cancel
Save