@@ -81,7 +81,7 @@ use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
81
81
use lightning:: ln:: peer_handler;
82
82
use lightning:: ln:: peer_handler:: SocketDescriptor as LnSocketTrait ;
83
83
use lightning:: ln:: peer_handler:: CustomMessageHandler ;
84
- use lightning:: ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler , NetAddress } ;
84
+ use lightning:: ln:: msgs:: { ChannelMessageHandler , OnionMessageHandler , NetAddress , RoutingMessageHandler } ;
85
85
use lightning:: util:: logger:: Logger ;
86
86
87
87
use std:: task;
@@ -120,9 +120,10 @@ struct Connection {
120
120
id : u64 ,
121
121
}
122
122
impl Connection {
123
- async fn poll_event_process < CMH , RMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > , Arc < UMH > > > , mut event_receiver : mpsc:: Receiver < ( ) > ) where
123
+ async fn poll_event_process < CMH , RMH , OMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < OMH > , Arc < L > , Arc < UMH > > > , mut event_receiver : mpsc:: Receiver < ( ) > ) where
124
124
CMH : ChannelMessageHandler + ' static + Send + Sync ,
125
125
RMH : RoutingMessageHandler + ' static + Send + Sync ,
126
+ OMH : OnionMessageHandler + ' static + Send + Sync ,
126
127
L : Logger + ' static + ?Sized + Send + Sync ,
127
128
UMH : CustomMessageHandler + ' static + Send + Sync {
128
129
loop {
@@ -133,9 +134,10 @@ impl Connection {
133
134
}
134
135
}
135
136
136
- 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
137
+ async fn schedule_read < CMH , RMH , OMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < OMH > , 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
137
138
CMH : ChannelMessageHandler + ' static + Send + Sync ,
138
139
RMH : RoutingMessageHandler + ' static + Send + Sync ,
140
+ OMH : OnionMessageHandler + ' static + Send + Sync ,
139
141
L : Logger + ' static + ?Sized + Send + Sync ,
140
142
UMH : CustomMessageHandler + ' static + Send + Sync {
141
143
// Create a waker to wake up poll_event_process, above
@@ -255,9 +257,10 @@ fn get_addr_from_stream(stream: &StdTcpStream) -> Option<NetAddress> {
255
257
/// The returned future will complete when the peer is disconnected and associated handling
256
258
/// futures are freed, though, because all processing futures are spawned with tokio::spawn, you do
257
259
/// not need to poll the provided future in order to make progress.
258
- 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
260
+ pub fn setup_inbound < CMH , RMH , OMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < OMH > , Arc < L > , Arc < UMH > > > , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
259
261
CMH : ChannelMessageHandler + ' static + Send + Sync ,
260
262
RMH : RoutingMessageHandler + ' static + Send + Sync ,
263
+ OMH : OnionMessageHandler + ' static + Send + Sync ,
261
264
L : Logger + ' static + ?Sized + Send + Sync ,
262
265
UMH : CustomMessageHandler + ' static + Send + Sync {
263
266
let remote_addr = get_addr_from_stream ( & stream) ;
@@ -297,9 +300,10 @@ pub fn setup_inbound<CMH, RMH, L, UMH>(peer_manager: Arc<peer_handler::PeerManag
297
300
/// The returned future will complete when the peer is disconnected and associated handling
298
301
/// futures are freed, though, because all processing futures are spawned with tokio::spawn, you do
299
302
/// not need to poll the provided future in order to make progress.
300
- 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
303
+ pub fn setup_outbound < CMH , RMH , OMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < OMH > , Arc < L > , Arc < UMH > > > , their_node_id : PublicKey , stream : StdTcpStream ) -> impl std:: future:: Future < Output =( ) > where
301
304
CMH : ChannelMessageHandler + ' static + Send + Sync ,
302
305
RMH : RoutingMessageHandler + ' static + Send + Sync ,
306
+ OMH : OnionMessageHandler + ' static + Send + Sync ,
303
307
L : Logger + ' static + ?Sized + Send + Sync ,
304
308
UMH : CustomMessageHandler + ' static + Send + Sync {
305
309
let remote_addr = get_addr_from_stream ( & stream) ;
@@ -368,9 +372,10 @@ pub fn setup_outbound<CMH, RMH, L, UMH>(peer_manager: Arc<peer_handler::PeerMana
368
372
/// disconnected and associated handling futures are freed, though, because all processing in said
369
373
/// futures are spawned with tokio::spawn, you do not need to poll the second future in order to
370
374
/// make progress.
371
- 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
375
+ pub async fn connect_outbound < CMH , RMH , OMH , L , UMH > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < OMH > , Arc < L > , Arc < UMH > > > , their_node_id : PublicKey , addr : SocketAddr ) -> Option < impl std:: future:: Future < Output =( ) > > where
372
376
CMH : ChannelMessageHandler + ' static + Send + Sync ,
373
377
RMH : RoutingMessageHandler + ' static + Send + Sync ,
378
+ OMH : OnionMessageHandler + ' static + Send + Sync ,
374
379
L : Logger + ' static + ?Sized + Send + Sync ,
375
380
UMH : CustomMessageHandler + ' static + Send + Sync {
376
381
if let Ok ( Ok ( stream) ) = time:: timeout ( Duration :: from_secs ( 10 ) , async { TcpStream :: connect ( & addr) . await . map ( |s| s. into_std ( ) . unwrap ( ) ) } ) . await {
@@ -618,6 +623,7 @@ mod tests {
618
623
let a_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
619
624
chan_handler : Arc :: clone ( & a_handler) ,
620
625
route_handler : Arc :: clone ( & a_handler) ,
626
+ onion_message_handler : Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ,
621
627
} , a_key. clone ( ) , & [ 1 ; 32 ] , Arc :: new ( TestLogger ( ) ) , Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ) ) ;
622
628
623
629
let ( b_connected_sender, mut b_connected) = mpsc:: channel ( 1 ) ;
@@ -632,6 +638,7 @@ mod tests {
632
638
let b_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
633
639
chan_handler : Arc :: clone ( & b_handler) ,
634
640
route_handler : Arc :: clone ( & b_handler) ,
641
+ onion_message_handler : Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ,
635
642
} , b_key. clone ( ) , & [ 2 ; 32 ] , Arc :: new ( TestLogger ( ) ) , Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ) ) ;
636
643
637
644
// We bind on localhost, hoping the environment is properly configured with a local
@@ -683,6 +690,7 @@ mod tests {
683
690
684
691
let a_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
685
692
chan_handler : Arc :: new ( lightning:: ln:: peer_handler:: ErroringMessageHandler :: new ( ) ) ,
693
+ onion_message_handler : Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ,
686
694
route_handler : Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ,
687
695
} , a_key, & [ 1 ; 32 ] , Arc :: new ( TestLogger ( ) ) , Arc :: new ( lightning:: ln:: peer_handler:: IgnoringMessageHandler { } ) ) ) ;
688
696
0 commit comments