diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-11-21 12:22:11 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-09 15:17:21 +0100 |
commit | bb424e4447a5b1e2f9592eed52f869426933f2c8 (patch) | |
tree | d84c581aae13ed69a5296cc19f89ae2ab03f6a31 | |
parent | cd5164aba2ff5f0e9f449e2b1bf50198311e8d7f (diff) | |
download | bitcoin-bb424e4447a5b1e2f9592eed52f869426933f2c8.tar.xz |
Limit the number of new addressses to accumulate
Rebased-From: 12a49cac0a561ada277e93549cae26a3123a6023
-rw-r--r-- | src/net.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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); } @@ -400,8 +402,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); + } + } } |