@@ -80,6 +80,7 @@ use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
80
80
81
81
use lightning:: ln:: peer_handler;
82
82
use lightning:: ln:: peer_handler:: SocketDescriptor as LnSocketTrait ;
83
+ use lightning:: ln:: peer_handler:: CustomMessageHandler ;
83
84
use lightning:: ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
84
85
use lightning:: util:: logger:: Logger ;
85
86
@@ -119,10 +120,11 @@ struct Connection {
119
120
id : u64 ,
120
121
}
121
122
impl Connection {
122
- async fn schedule_read < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , us : Arc < Mutex < Self > > , mut reader : io:: ReadHalf < TcpStream > , mut read_wake_receiver : mpsc:: Receiver < ( ) > , mut write_avail_receiver : mpsc:: Receiver < ( ) > ) where
123
+ async fn schedule_read < CMH , RMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > , Arc < UMH > > > , us : Arc < Mutex < Self > > , mut reader : io:: ReadHalf < TcpStream > , mut read_wake_receiver : mpsc:: Receiver < ( ) > , mut write_avail_receiver : mpsc:: Receiver < ( ) > ) where
123
124
CMH : ChannelMessageHandler + ' static ,
124
125
RMH : RoutingMessageHandler + ' static ,
125
- L : Logger + ' static + ?Sized {
126
+ L : Logger + ' static + ?Sized ,
127
+ UMH : CustomMessageHandler + ' static {
126
128
// 8KB is nice and big but also should never cause any issues with stack overflowing.
127
129
let mut buf = [ 0 ; 8192 ] ;
128
130
@@ -222,10 +224,11 @@ impl Connection {
222
224
/// The returned future will complete when the peer is disconnected and associated handling
223
225
/// futures are freed, though, because all processing futures are spawned with tokio::spawn, you do
224
226
/// not need to poll the provided future in order to make progress.
225
- pub fn setup_inbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
227
+ pub fn setup_inbound < CMH , RMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > , Arc < UMH > > > , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
226
228
CMH : ChannelMessageHandler + ' static + Send + Sync ,
227
229
RMH : RoutingMessageHandler + ' static + Send + Sync ,
228
- L : Logger + ' static + ?Sized + Send + Sync {
230
+ L : Logger + ' static + ?Sized + Send + Sync ,
231
+ UMH : CustomMessageHandler + ' static + Send + Sync {
229
232
let ( reader, write_receiver, read_receiver, us) = Connection :: new ( stream) ;
230
233
#[ cfg( debug_assertions) ]
231
234
let last_us = Arc :: clone ( & us) ;
@@ -262,10 +265,11 @@ pub fn setup_inbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<So
262
265
/// The returned future will complete when the peer is disconnected and associated handling
263
266
/// futures are freed, though, because all processing futures are spawned with tokio::spawn, you do
264
267
/// not need to poll the provided future in order to make progress.
265
- pub fn setup_outbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , their_node_id : PublicKey , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
268
+ pub fn setup_outbound < CMH , RMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > , Arc < UMH > > > , their_node_id : PublicKey , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
266
269
CMH : ChannelMessageHandler + ' static + Send + Sync ,
267
270
RMH : RoutingMessageHandler + ' static + Send + Sync ,
268
- L : Logger + ' static + ?Sized + Send + Sync {
271
+ L : Logger + ' static + ?Sized + Send + Sync ,
272
+ UMH : CustomMessageHandler + ' static + Send + Sync {
269
273
let ( reader, mut write_receiver, read_receiver, us) = Connection :: new ( stream) ;
270
274
#[ cfg( debug_assertions) ]
271
275
let last_us = Arc :: clone ( & us) ;
@@ -332,10 +336,11 @@ pub fn setup_outbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<S
332
336
/// disconnected and associated handling futures are freed, though, because all processing in said
333
337
/// futures are spawned with tokio::spawn, you do not need to poll the second future in order to
334
338
/// make progress.
335
- pub async fn connect_outbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , their_node_id : PublicKey , addr : SocketAddr ) -> Option < impl std:: future:: Future < Output =( ) > > where
339
+ pub async fn connect_outbound < CMH , RMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > , Arc < UMH > > > , their_node_id : PublicKey , addr : SocketAddr ) -> Option < impl std:: future:: Future < Output =( ) > > where
336
340
CMH : ChannelMessageHandler + ' static + Send + Sync ,
337
341
RMH : RoutingMessageHandler + ' static + Send + Sync ,
338
- L : Logger + ' static + ?Sized + Send + Sync {
342
+ L : Logger + ' static + ?Sized + Send + Sync ,
343
+ UMH : CustomMessageHandler + ' static + Send + Sync {
339
344
if let Ok ( Ok ( stream) ) = time:: timeout ( Duration :: from_secs ( 10 ) , async { TcpStream :: connect ( & addr) . await . map ( |s| s. into_std ( ) . unwrap ( ) ) } ) . await {
340
345
Some ( setup_outbound ( peer_manager, their_node_id, stream) )
341
346
} else { None }
@@ -563,7 +568,7 @@ mod tests {
563
568
let a_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
564
569
chan_handler : Arc :: clone ( & a_handler) ,
565
570
route_handler : Arc :: clone ( & a_handler) ,
566
- } , a_key. clone ( ) , & [ 1 ; 32 ] , Arc :: new ( TestLogger ( ) ) ) ) ;
571
+ } , a_key. clone ( ) , & [ 1 ; 32 ] , Arc :: new ( TestLogger ( ) ) , Arc :: new ( lightning :: ln :: peer_handler :: IgnoringCustomMessageHandler { } ) ) ) ;
567
572
568
573
let ( b_connected_sender, mut b_connected) = mpsc:: channel ( 1 ) ;
569
574
let ( b_disconnected_sender, mut b_disconnected) = mpsc:: channel ( 1 ) ;
@@ -577,7 +582,7 @@ mod tests {
577
582
let b_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
578
583
chan_handler : Arc :: clone ( & b_handler) ,
579
584
route_handler : Arc :: clone ( & b_handler) ,
580
- } , b_key. clone ( ) , & [ 2 ; 32 ] , Arc :: new ( TestLogger ( ) ) ) ) ;
585
+ } , b_key. clone ( ) , & [ 2 ; 32 ] , Arc :: new ( TestLogger ( ) ) , Arc :: new ( lightning :: ln :: peer_handler :: IgnoringCustomMessageHandler { } ) ) ) ;
581
586
582
587
// We bind on localhost, hoping the environment is properly configured with a local
583
588
// address. This may not always be the case in containers and the like, so if this test is
0 commit comments