@@ -35,10 +35,9 @@ use std::rc::Rc;
3535use std:: sync:: { Arc , Mutex } ;
3636use std:: mem;
3737use std:: ops:: Deref ;
38- use std:: marker:: Sized ;
3938
4039pub const CHAN_CONFIRM_DEPTH : u32 = 100 ;
41- pub fn confirm_transaction ( notifier : & chaininterface:: BlockNotifier , chain : & chaininterface:: ChainWatchInterfaceUtil , tx : & Transaction , chan_id : u32 ) {
40+ pub fn confirm_transaction < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( notifier : & chaininterface:: BlockNotifier < CL > , chain : & chaininterface:: ChainWatchInterfaceUtil , tx : & Transaction , chan_id : u32 ) {
4241 assert ! ( chain. does_match_tx( tx) ) ;
4342 let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4443 notifier. block_connected_checked ( & header, 1 , & [ tx; 1 ] , & [ chan_id; 1 ] ) ;
@@ -48,7 +47,7 @@ pub fn confirm_transaction(notifier: &chaininterface::BlockNotifier, chain: &cha
4847 }
4948}
5049
51- pub fn connect_blocks ( notifier : & chaininterface:: BlockNotifier , depth : u32 , height : u32 , parent : bool , prev_blockhash : Sha256d ) -> Sha256d {
50+ pub fn connect_blocks < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( notifier : & chaininterface:: BlockNotifier < CL > , depth : u32 , height : u32 , parent : bool , prev_blockhash : Sha256d ) -> Sha256d {
5251 let mut header = BlockHeader { version : 0x2000000 , prev_blockhash : if parent { prev_blockhash } else { Default :: default ( ) } , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
5352 notifier. block_connected_checked ( & header, height + 1 , & Vec :: new ( ) , & Vec :: new ( ) ) ;
5453 for i in 2 ..depth + 1 {
@@ -59,7 +58,7 @@ pub fn connect_blocks(notifier: &chaininterface::BlockNotifier, depth: u32, heig
5958}
6059
6160pub struct Node {
62- pub block_notifier : Arc < chaininterface:: BlockNotifier > ,
61+ pub block_notifier : Arc < chaininterface:: BlockNotifier < Arc < chaininterface :: ChainListener > > > ,
6362 pub chain_monitor : Arc < chaininterface:: ChainWatchInterfaceUtil > ,
6463 pub tx_broadcaster : Arc < test_utils:: TestBroadcaster > ,
6564 pub chan_monitor : Arc < test_utils:: TestChannelMonitor > ,
@@ -858,14 +857,12 @@ pub fn create_network(node_count: usize, node_config: &[Option<UserConfig>]) ->
858857 rng. fill_bytes ( & mut seed) ;
859858 let keys_manager = Arc :: new ( test_utils:: TestKeysInterface :: new ( & seed, Network :: Testnet , Arc :: clone ( & logger) ) ) ;
860859 let chan_monitor = Arc :: new ( test_utils:: TestChannelMonitor :: new ( chain_monitor. clone ( ) , tx_broadcaster. clone ( ) , logger. clone ( ) , feeest. clone ( ) ) ) ;
861- let weak_res = Arc :: downgrade ( & chan_monitor. simple_monitor ) ;
862- block_notifier. register_listener ( weak_res) ;
860+ block_notifier. register_listener ( chan_monitor. simple_monitor . clone ( ) as Arc < chaininterface:: ChainListener > ) ;
863861 let mut default_config = UserConfig :: default ( ) ;
864862 default_config. channel_options . announced_channel = true ;
865863 default_config. peer_channel_config_limits . force_announced_channel_preference = false ;
866864 let node = ChannelManager :: new ( Network :: Testnet , feeest. clone ( ) , chan_monitor. clone ( ) as Arc < ManyChannelMonitor > , tx_broadcaster. clone ( ) , Arc :: clone ( & logger) , keys_manager. clone ( ) , if node_config[ i] . is_some ( ) { node_config[ i] . clone ( ) . unwrap ( ) } else { default_config } , 0 ) . unwrap ( ) ;
867- let weak_res = Arc :: downgrade ( & node) ;
868- block_notifier. register_listener ( weak_res) ;
865+ block_notifier. register_listener ( node. clone ( ) ) ;
869866 let router = Router :: new ( PublicKey :: from_secret_key ( & secp_ctx, & keys_manager. get_node_secret ( ) ) , chain_monitor. clone ( ) , Arc :: clone ( & logger) ) ;
870867 nodes. push ( Node { chain_monitor, tx_broadcaster, chan_monitor, node, router, keys_manager, node_seed : seed,
871868 network_payment_count : payment_count. clone ( ) ,
0 commit comments