@@ -722,14 +722,17 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
722
722
}
723
723
}
724
724
725
- /// Append a message to a peer's pending outbound/write buffer, and update the map of peers needing sends accordingly.
725
+ /// Append a message to a peer's pending outbound/write buffer
726
+ fn enqueue_encoded_message ( & self , peer : & mut Peer , encoded_message : & Vec < u8 > ) {
727
+ peer. pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encoded_message[ ..] ) ) ;
728
+ }
729
+
730
+ /// Append a message to a peer's pending outbound/write buffer
726
731
fn enqueue_message < M : wire:: Type > ( & self , peer : & mut Peer , message : & M ) {
727
732
let mut buffer = VecWriter ( Vec :: with_capacity ( 2048 ) ) ;
728
733
wire:: write ( message, & mut buffer) . unwrap ( ) ; // crash if the write failed
729
- let encoded_message = buffer. 0 ;
730
-
731
734
log_trace ! ( self . logger, "Enqueueing message {:?} to {}" , message, log_pubkey!( peer. their_node_id. unwrap( ) ) ) ;
732
- peer . pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encoded_message [ .. ] ) ) ;
735
+ self . enqueue_encoded_message ( peer, & buffer . 0 ) ;
733
736
}
734
737
735
738
fn do_read_event ( & self , peer_descriptor : & mut Descriptor , data : & [ u8 ] ) -> Result < bool , PeerHandleError > {
@@ -1118,7 +1121,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1118
1121
if except_node. is_some ( ) && peer. their_node_id . as_ref ( ) == except_node {
1119
1122
continue ;
1120
1123
}
1121
- peer . pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encoded_msg[ .. ] ) ) ;
1124
+ self . enqueue_encoded_message ( peer, & encoded_msg) ;
1122
1125
}
1123
1126
} ,
1124
1127
wire:: Message :: NodeAnnouncement ( ref msg) => {
@@ -1140,7 +1143,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1140
1143
if except_node. is_some ( ) && peer. their_node_id . as_ref ( ) == except_node {
1141
1144
continue ;
1142
1145
}
1143
- peer . pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encoded_msg[ .. ] ) ) ;
1146
+ self . enqueue_encoded_message ( peer, & encoded_msg) ;
1144
1147
}
1145
1148
} ,
1146
1149
wire:: Message :: ChannelUpdate ( ref msg) => {
@@ -1159,7 +1162,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
1159
1162
if except_node. is_some ( ) && peer. their_node_id . as_ref ( ) == except_node {
1160
1163
continue ;
1161
1164
}
1162
- peer . pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encoded_msg[ .. ] ) ) ;
1165
+ self . enqueue_encoded_message ( peer, & encoded_msg) ;
1163
1166
}
1164
1167
} ,
1165
1168
_ => debug_assert ! ( false , "We shouldn't attempt to forward anything but gossip messages" ) ,
0 commit comments