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

66b0724 Only send one GetAddr response per connection. (Gregory Maxwell)
This commit is contained in:
Wladimir J. van der Laan 2016-04-15 09:02:41 +02:00 committed by Alexander Block
parent b2eabb0974
commit 24f8c248f5
3 changed files with 10 additions and 0 deletions

View File

@ -2708,6 +2708,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
nNextAddrSend = 0;
nNextInvSend = 0;
fRelayTxes = false;
fSentAddr = false;
pfilter = new CBloomFilter();
nLastBlockTime = 0;
nLastTXTime = 0;

View File

@ -709,6 +709,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;
// If 'true' this node will be disconnected on CMasternodeMan::ProcessMasternodeConnections()
bool fMasternode;
CSemaphoreGrant grantOutbound;

View File

@ -1938,6 +1938,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 = connman.GetAddresses();
BOOST_FOREACH(const CAddress &addr, vAddr)