@@ -35,10 +35,9 @@ use std::rc::Rc;
35
35
use std:: sync:: { Arc , Mutex } ;
36
36
use std:: mem;
37
37
use std:: ops:: Deref ;
38
- use std:: marker:: Sized ;
39
38
40
39
pub 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 ) {
42
41
assert ! ( chain. does_match_tx( tx) ) ;
43
42
let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
44
43
notifier. block_connected_checked ( & header, 1 , & [ tx; 1 ] , & [ chan_id; 1 ] ) ;
@@ -48,7 +47,7 @@ pub fn confirm_transaction(notifier: &chaininterface::BlockNotifier, chain: &cha
48
47
}
49
48
}
50
49
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 {
52
51
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 } ;
53
52
notifier. block_connected_checked ( & header, height + 1 , & Vec :: new ( ) , & Vec :: new ( ) ) ;
54
53
for i in 2 ..depth + 1 {
@@ -59,7 +58,7 @@ pub fn connect_blocks(notifier: &chaininterface::BlockNotifier, depth: u32, heig
59
58
}
60
59
61
60
pub struct Node {
62
- pub block_notifier : Arc < chaininterface:: BlockNotifier > ,
61
+ pub block_notifier : Arc < chaininterface:: BlockNotifier < Arc < chaininterface :: ChainListener > > > ,
63
62
pub chain_monitor : Arc < chaininterface:: ChainWatchInterfaceUtil > ,
64
63
pub tx_broadcaster : Arc < test_utils:: TestBroadcaster > ,
65
64
pub chan_monitor : Arc < test_utils:: TestChannelMonitor > ,
@@ -858,14 +857,12 @@ pub fn create_network(node_count: usize, node_config: &[Option<UserConfig>]) ->
858
857
rng. fill_bytes ( & mut seed) ;
859
858
let keys_manager = Arc :: new ( test_utils:: TestKeysInterface :: new ( & seed, Network :: Testnet , Arc :: clone ( & logger) ) ) ;
860
859
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 > ) ;
863
861
let mut default_config = UserConfig :: default ( ) ;
864
862
default_config. channel_options . announced_channel = true ;
865
863
default_config. peer_channel_config_limits . force_announced_channel_preference = false ;
866
864
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 ( ) ) ;
869
866
let router = Router :: new ( PublicKey :: from_secret_key ( & secp_ctx, & keys_manager. get_node_secret ( ) ) , chain_monitor. clone ( ) , Arc :: clone ( & logger) ) ;
870
867
nodes. push ( Node { chain_monitor, tx_broadcaster, chan_monitor, node, router, keys_manager, node_seed : seed,
871
868
network_payment_count : payment_count. clone ( ) ,
0 commit comments