Skip to content

Commit

Permalink
Limit the number of new addressses to accumulate
Browse files Browse the repository at this point in the history
Rebased-From: 12a49ca
  • Loading branch information
sipa authored and laanwj committed Dec 9, 2014
1 parent cd5164a commit bb424e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace boost {
static const unsigned int MAX_INV_SZ = 50000;
/** The maximum number of entries in mapAskFor */
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
/** The maximum number of new addresses to accumulate before announcing. */
static const unsigned int MAX_ADDR_TO_SEND = 1000;

inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
Expand Down Expand Up @@ -400,8 +402,13 @@ class CNode
// Known checking here is only to save space from duplicates.
// SendMessages will filter it again for knowns that were added
// after addresses were pushed.
if (addr.IsValid() && !setAddrKnown.count(addr))
vAddrToSend.push_back(addr);
if (addr.IsValid() && !setAddrKnown.count(addr)) {
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
vAddrToSend[insecure_rand() % vAddrToSend.size()] = addr;
} else {
vAddrToSend.push_back(addr);
}
}
}


Expand Down

0 comments on commit bb424e4

Please sign in to comment.