diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-11-21 12:22:11 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-12-04 13:19:16 +0100 |
commit | 12a49cac0a561ada277e93549cae26a3123a6023 (patch) | |
tree | f70b2eea6568a26e3941e12b5d078a8161c10075 | |
parent | a0417b8cc840ff6f49b4fb1f8ceef54f8e3d0df1 (diff) |
Limit the number of new addressses to accumulate
-rw-r--r-- | src/net.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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: // 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); + } + } } |