diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-05 10:54:22 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-05 11:01:19 +0100 |
commit | 68705996a9e486824e08d1ca4f906be35592f5fd (patch) | |
tree | 1f325068720114f3b3b33377ef3356c7a23aa0c0 /src | |
parent | 9ddc8c63ab72a6951f0c4f636b3252a43193a45b (diff) | |
parent | 12a49cac0a561ada277e93549cae26a3123a6023 (diff) |
Merge pull request #5419
12a49ca Limit the number of new addressses to accumulate (Pieter Wuille)
Diffstat (limited to 'src')
-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); + } + } } |