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;
44
44
static const int TIMEOUT_INTERVAL = 20 * 60 ;
45
45
/* * The maximum number of entries in an 'inv' protocol message */
46
46
static 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 ;
47
49
/* * -listen default */
48
50
static const bool DEFAULT_LISTEN = true ;
49
51
/* * -upnp default */
@@ -368,8 +370,13 @@ class CNode
368
370
// Known checking here is only to save space from duplicates.
369
371
// SendMessages will filter it again for knowns that were added
370
372
// 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
+ }
373
380
}
374
381
375
382
You can’t perform that action at this time.
0 commit comments