Browse Source

Merge pull request #5419

12a49ca Limit the number of new addressses to accumulate (Pieter Wuille)
0.10
Wladimir J. van der Laan 10 years ago
parent
commit
68705996a9
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 11
      src/net.h

11
src/net.h

@ -44,6 +44,8 @@ static const int PING_INTERVAL = 2 * 60; @@ -44,6 +44,8 @@ static const int PING_INTERVAL = 2 * 60;
static const int TIMEOUT_INTERVAL = 20 * 60;
/** The maximum number of entries in an 'inv' protocol message */
static const unsigned int MAX_INV_SZ = 50000;
/** The maximum number of new addresses to accumulate before announcing. */
static const unsigned int MAX_ADDR_TO_SEND = 1000;
/** -listen default */
static const bool DEFAULT_LISTEN = true;
/** -upnp default */
@ -368,8 +370,13 @@ public: @@ -368,8 +370,13 @@ public:
// 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);
}
}
}

Loading…
Cancel
Save