@@ -378,6 +378,14 @@ impl Peer {
378
378
InitSyncTracker :: NodesSyncing ( pk) => pk < node_id,
379
379
}
380
380
}
381
+ /// Returns whether this peer's buffer is full and we should drop gossip messages.
382
+ fn buffer_full_drop_gossip ( & self ) -> bool {
383
+ if self . pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
384
+ || self . msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO {
385
+ return false
386
+ }
387
+ true
388
+ }
381
389
}
382
390
383
391
/// SimpleArcPeerManager is useful when you need a PeerManager with a static lifetime, e.g.
@@ -1308,9 +1316,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1308
1316
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1309
1317
continue
1310
1318
}
1311
- if peer. pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
1312
- || peer. msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO
1313
- {
1319
+ if peer. buffer_full_drop_gossip ( ) {
1314
1320
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1315
1321
continue ;
1316
1322
}
@@ -1334,9 +1340,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1334
1340
!peer. should_forward_node_announcement ( msg. contents . node_id ) {
1335
1341
continue
1336
1342
}
1337
- if peer. pending_outbound_buffer . len ( ) > OUTBOUND_BUFFER_LIMIT_DROP_GOSSIP
1338
- || peer. msgs_sent_since_pong > BUFFER_DRAIN_MSGS_PER_TICK * FORWARD_INIT_SYNC_BUFFER_LIMIT_RATIO
1339
- {
1343
+ if peer. buffer_full_drop_gossip ( ) {
1340
1344
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1341
1345
continue ;
1342
1346
}
@@ -1359,9 +1363,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1359
1363
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1360
1364
continue
1361
1365
}
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
- {
1366
+ if peer. buffer_full_drop_gossip ( ) {
1365
1367
log_gossip ! ( self . logger, "Skipping broadcast message to {:?} as its outbound buffer is full" , peer. their_node_id) ;
1366
1368
continue ;
1367
1369
}
0 commit comments