File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ static const int PING_INTERVAL = 2 * 60;
4444static const int TIMEOUT_INTERVAL = 20 * 60 ;
4545/* * The maximum number of entries in an 'inv' protocol message */
4646static const unsigned int MAX_INV_SZ = 50000 ;
47+ /* * The maximum number of new addresses to accumulate before announcing. */
48+ static const unsigned int MAX_ADDR_TO_SEND = 1000 ;
4749/* * -listen default */
4850static const bool DEFAULT_LISTEN = true ;
4951/* * -upnp default */
@@ -368,8 +370,13 @@ class CNode
368370 // Known checking here is only to save space from duplicates.
369371 // SendMessages will filter it again for knowns that were added
370372 // after addresses were pushed.
371- if (addr.IsValid () && !setAddrKnown.count (addr))
372- vAddrToSend.push_back (addr);
373+ if (addr.IsValid () && !setAddrKnown.count (addr)) {
374+ if (vAddrToSend.size () >= MAX_ADDR_TO_SEND) {
375+ vAddrToSend[insecure_rand () % vAddrToSend.size ()] = addr;
376+ } else {
377+ vAddrToSend.push_back (addr);
378+ }
379+ }
373380 }
374381
375382
You can’t perform that action at this time.
0 commit comments