@@ -393,6 +393,14 @@ impl Peer {
393
393
InitSyncTracker :: NodesSyncing ( pk) => pk < node_id,
394
394
}
395
395
}
396
+ /// Returns whether this peer's buffer is full and we should drop gossip messages.
397
+ fn buffer_full_drop_gossip ( & self ) -> bool {
398
+ if self . pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
399
+ || self . msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO {
400
+ return false
401
+ }
402
+ true
403
+ }
396
404
}
397
405
398
406
/// SimpleArcPeerManager is useful when you need a PeerManager with a static lifetime, e.g.
@@ -1333,9 +1341,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1333
1341
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1334
1342
continue
1335
1343
}
1336
- if peer. pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
1337
- || peer. msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO
1338
- {
1344
+ if peer. buffer_full_drop_gossip ( ) {
1339
1345
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1340
1346
continue ;
1341
1347
}
@@ -1359,9 +1365,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1359
1365
!peer. should_forward_node_announcement ( msg. contents . node_id ) {
1360
1366
continue
1361
1367
}
1362
- if peer. pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
1363
- || peer. msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO
1364
- {
1368
+ if peer. buffer_full_drop_gossip ( ) {
1365
1369
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1366
1370
continue ;
1367
1371
}
@@ -1384,9 +1388,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1384
1388
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1385
1389
continue
1386
1390
}
1387
- if peer. pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
1388
- || peer. msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO
1389
- {
1391
+ if peer. buffer_full_drop_gossip ( ) {
1390
1392
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1391
1393
continue ;
1392
1394
}
0 commit comments