@@ -444,7 +444,7 @@ impl Peer {
444
444
/// point and we shouldn't send it yet to avoid sending duplicate updates. If we've already
445
445
/// sent the old versions, we should send the update, and so return true here.
446
446
fn should_forward_channel_announcement ( & self , channel_id : u64 ) -> bool {
447
- if self . their_features . is_none ( ) { return false ; }
447
+ if ! self . handshake_complete ( ) { return false ; }
448
448
if self . their_features . as_ref ( ) . unwrap ( ) . supports_gossip_queries ( ) &&
449
449
!self . sent_gossip_timestamp_filter {
450
450
return false ;
@@ -485,20 +485,20 @@ impl Peer {
485
485
fn should_buffer_gossip_backfill ( & self ) -> bool {
486
486
self . pending_outbound_buffer . is_empty ( ) && self . gossip_broadcast_buffer . is_empty ( )
487
487
&& self . msgs_sent_since_pong < BUFFER_DRAIN_MSGS_PER_TICK
488
- && self . their_features . is_some ( )
488
+ && self . handshake_complete ( )
489
489
}
490
490
491
491
/// Determines if we should push an onion message onto a peer's outbound buffer. This is checked
492
492
/// every time the peer's buffer may have been drained.
493
493
fn should_buffer_onion_message ( & self ) -> bool {
494
- self . pending_outbound_buffer . is_empty ( ) && self . their_features . is_some ( )
494
+ self . pending_outbound_buffer . is_empty ( ) && self . handshake_complete ( )
495
495
&& self . msgs_sent_since_pong < BUFFER_DRAIN_MSGS_PER_TICK
496
496
}
497
497
498
498
/// Determines if we should push additional gossip broadcast messages onto a peer's outbound
499
499
/// buffer. This is checked every time the peer's buffer may have been drained.
500
500
fn should_buffer_gossip_broadcast ( & self ) -> bool {
501
- self . pending_outbound_buffer . is_empty ( ) && self . their_features . is_some ( )
501
+ self . pending_outbound_buffer . is_empty ( ) && self . handshake_complete ( )
502
502
&& self . msgs_sent_since_pong < BUFFER_DRAIN_MSGS_PER_TICK
503
503
}
504
504
@@ -780,8 +780,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
780
780
let peers = self . peers . read ( ) . unwrap ( ) ;
781
781
peers. values ( ) . filter_map ( |peer_mutex| {
782
782
let p = peer_mutex. lock ( ) . unwrap ( ) ;
783
- if !p. channel_encryptor . is_ready_for_encryption ( ) || p. their_features . is_none ( ) ||
784
- p. their_node_id . is_none ( ) {
783
+ if !p. handshake_complete ( ) {
785
784
return None ;
786
785
}
787
786
Some ( ( p. their_node_id . unwrap ( ) . 0 , p. their_net_address . clone ( ) ) )
@@ -1540,7 +1539,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1540
1539
1541
1540
for ( _, peer_mutex) in peers. iter ( ) {
1542
1541
let mut peer = peer_mutex. lock ( ) . unwrap ( ) ;
1543
- if peer. their_features . is_none ( ) ||
1542
+ if peer. handshake_complete ( ) ||
1544
1543
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1545
1544
continue
1546
1545
}
@@ -1567,7 +1566,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1567
1566
1568
1567
for ( _, peer_mutex) in peers. iter ( ) {
1569
1568
let mut peer = peer_mutex. lock ( ) . unwrap ( ) ;
1570
- if peer. their_features . is_none ( ) ||
1569
+ if peer. handshake_complete ( ) ||
1571
1570
!peer. should_forward_node_announcement ( msg. contents . node_id ) {
1572
1571
continue
1573
1572
}
@@ -1594,7 +1593,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1594
1593
1595
1594
for ( _, peer_mutex) in peers. iter ( ) {
1596
1595
let mut peer = peer_mutex. lock ( ) . unwrap ( ) ;
1597
- if peer. their_features . is_none ( ) ||
1596
+ if peer. handshake_complete ( ) ||
1598
1597
!peer. should_forward_channel_announcement ( msg. contents . short_channel_id ) {
1599
1598
continue
1600
1599
}
@@ -1679,7 +1678,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
1679
1678
Some ( descriptor) => match peers. get( & descriptor) {
1680
1679
Some ( peer_mutex) => {
1681
1680
let peer_lock = peer_mutex. lock( ) . unwrap( ) ;
1682
- if peer_lock. their_features . is_none ( ) {
1681
+ if ! peer_lock. handshake_complete ( ) {
1683
1682
continue ;
1684
1683
}
1685
1684
peer_lock
@@ -2033,7 +2032,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
2033
2032
let mut peer = peer_mutex. lock ( ) . unwrap ( ) ;
2034
2033
if flush_read_disabled { peer. received_channel_announce_since_backlogged = false ; }
2035
2034
2036
- if peer. their_features . is_none ( ) {
2035
+ if ! peer. handshake_complete ( ) {
2037
2036
// The peer needs to complete its handshake before we can exchange messages. We
2038
2037
// give peers one timer tick to complete handshake, reusing
2039
2038
// `awaiting_pong_timer_tick_intervals` to track number of timer ticks taken
0 commit comments