28
28
//! type ChainWatchInterface = dyn lightning::chain::chaininterface::ChainWatchInterface;
29
29
//! type ChannelMonitor = lightning::ln::channelmonitor::SimpleManyChannelMonitor<lightning::chain::transaction::OutPoint, lightning::chain::keysinterface::InMemoryChannelKeys, Arc<TxBroadcaster>, Arc<FeeEstimator>, Arc<Logger>, Arc<ChainWatchInterface>>;
30
30
//! type ChannelManager = lightning::ln::channelmanager::SimpleArcChannelManager<ChannelMonitor, TxBroadcaster, FeeEstimator, Logger>;
31
- //! type PeerManager = lightning::ln::peer_handler::SimpleArcPeerManager<lightning_net_tokio::SocketDescriptor, ChannelMonitor, TxBroadcaster, FeeEstimator, Logger>;
31
+ //! type PeerManager = lightning::ln::peer_handler::SimpleArcPeerManager<lightning_net_tokio::SocketDescriptor, ChannelMonitor, TxBroadcaster, FeeEstimator, ChainWatchInterface, Logger>;
32
32
//!
33
33
//! // Connect to node with pubkey their_node_id at addr:
34
34
//! async fn connect_to_node(peer_manager: PeerManager, channel_monitor: Arc<ChannelMonitor>, channel_manager: ChannelManager, their_node_id: PublicKey, addr: SocketAddr) {
@@ -70,7 +70,7 @@ use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
70
70
71
71
use lightning:: ln:: peer_handler;
72
72
use lightning:: ln:: peer_handler:: SocketDescriptor as LnSocketTrait ;
73
- use lightning:: ln:: msgs:: ChannelMessageHandler ;
73
+ use lightning:: ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
74
74
use lightning:: util:: logger:: Logger ;
75
75
76
76
use std:: { task, thread} ;
@@ -124,7 +124,10 @@ impl Connection {
124
124
_ => panic ! ( )
125
125
}
126
126
}
127
- async fn schedule_read < CMH : ChannelMessageHandler + ' static , L : Logger + ' static + ?Sized > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < L > > > , us : Arc < Mutex < Self > > , mut reader : io:: ReadHalf < TcpStream > , mut read_wake_receiver : mpsc:: Receiver < ( ) > , mut write_avail_receiver : mpsc:: Receiver < ( ) > ) {
127
+ 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
128
+ CMH : ChannelMessageHandler + ' static ,
129
+ RMH : RoutingMessageHandler + ' static ,
130
+ L : Logger + ' static + ?Sized {
128
131
let peer_manager_ref = peer_manager. clone ( ) ;
129
132
// 8KB is nice and big but also should never cause any issues with stack overflowing.
130
133
let mut buf = [ 0 ; 8192 ] ;
@@ -234,7 +237,10 @@ impl Connection {
234
237
/// not need to poll the provided future in order to make progress.
235
238
///
236
239
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
237
- pub fn setup_inbound < CMH : ChannelMessageHandler + ' static , L : Logger + ' static + ?Sized > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , stream : TcpStream ) -> impl std:: future:: Future < Output =( ) > {
240
+ pub fn setup_inbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , stream : TcpStream ) -> impl std:: future:: Future < Output =( ) > where
241
+ CMH : ChannelMessageHandler + ' static ,
242
+ RMH : RoutingMessageHandler + ' static ,
243
+ L : Logger + ' static + ?Sized {
238
244
let ( reader, write_receiver, read_receiver, us) = Connection :: new ( event_notify, stream) ;
239
245
#[ cfg( debug_assertions) ]
240
246
let last_us = Arc :: clone ( & us) ;
@@ -273,7 +279,10 @@ pub fn setup_inbound<CMH: ChannelMessageHandler + 'static, L: Logger + 'static +
273
279
/// not need to poll the provided future in order to make progress.
274
280
///
275
281
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
276
- pub fn setup_outbound < CMH : ChannelMessageHandler + ' static , L : Logger + ' static + ?Sized > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , their_node_id : PublicKey , stream : TcpStream ) -> impl std:: future:: Future < Output =( ) > {
282
+ pub fn setup_outbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , their_node_id : PublicKey , stream : TcpStream ) -> impl std:: future:: Future < Output =( ) > where
283
+ CMH : ChannelMessageHandler + ' static ,
284
+ RMH : RoutingMessageHandler + ' static ,
285
+ L : Logger + ' static + ?Sized {
277
286
let ( reader, mut write_receiver, read_receiver, us) = Connection :: new ( event_notify, stream) ;
278
287
#[ cfg( debug_assertions) ]
279
288
let last_us = Arc :: clone ( & us) ;
@@ -342,7 +351,10 @@ pub fn setup_outbound<CMH: ChannelMessageHandler + 'static, L: Logger + 'static
342
351
/// make progress.
343
352
///
344
353
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
345
- pub async fn connect_outbound < CMH : ChannelMessageHandler + ' static , L : Logger + ' static + ?Sized > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , their_node_id : PublicKey , addr : SocketAddr ) -> Option < impl std:: future:: Future < Output =( ) > > {
354
+ pub async fn connect_outbound < CMH , RMH , L > ( peer_manager : Arc < peer_handler:: PeerManager < SocketDescriptor , Arc < CMH > , Arc < RMH > , Arc < L > > > , event_notify : mpsc:: Sender < ( ) > , their_node_id : PublicKey , addr : SocketAddr ) -> Option < impl std:: future:: Future < Output =( ) > > where
355
+ CMH : ChannelMessageHandler + ' static ,
356
+ RMH : RoutingMessageHandler + ' static ,
357
+ L : Logger + ' static + ?Sized {
346
358
if let Ok ( Ok ( stream) ) = time:: timeout ( Duration :: from_secs ( 10 ) , TcpStream :: connect ( & addr) ) . await {
347
359
Some ( setup_outbound ( peer_manager, event_notify, their_node_id, stream) )
348
360
} else { None }
@@ -568,7 +580,7 @@ mod tests {
568
580
} ) ;
569
581
let a_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
570
582
chan_handler : Arc :: clone ( & a_handler) ,
571
- route_handler : Arc :: clone ( & a_handler) as Arc < dyn RoutingMessageHandler > ,
583
+ route_handler : Arc :: clone ( & a_handler) ,
572
584
} , a_key. clone ( ) , & [ 1 ; 32 ] , Arc :: new ( TestLogger ( ) ) ) ) ;
573
585
574
586
let ( b_connected_sender, mut b_connected) = mpsc:: channel ( 1 ) ;
@@ -581,7 +593,7 @@ mod tests {
581
593
} ) ;
582
594
let b_manager = Arc :: new ( PeerManager :: new ( MessageHandler {
583
595
chan_handler : Arc :: clone ( & b_handler) ,
584
- route_handler : Arc :: clone ( & b_handler) as Arc < dyn RoutingMessageHandler > ,
596
+ route_handler : Arc :: clone ( & b_handler) ,
585
597
} , b_key. clone ( ) , & [ 2 ; 32 ] , Arc :: new ( TestLogger ( ) ) ) ) ;
586
598
587
599
// We bind on localhost, hoping the environment is properly configured with a local
0 commit comments