@@ -46,41 +46,47 @@ use std::collections::HashMap;
46
46
pub const CHAN_CONFIRM_DEPTH : u32 = 100 ;
47
47
48
48
pub fn confirm_transaction < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction ) {
49
- let notifier = & node. block_notifier ;
50
49
let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
51
50
let dummy_tx_count = tx. version as usize ;
52
51
let mut block = Block {
53
52
header : BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ,
54
53
txdata : vec ! [ dummy_tx; dummy_tx_count] ,
55
54
} ;
56
55
block. txdata . push ( tx. clone ( ) ) ;
57
- notifier . block_connected ( & block, 1 ) ;
56
+ connect_block ( node , & block, 1 ) ;
58
57
for i in 2 ..CHAN_CONFIRM_DEPTH {
59
58
block = Block {
60
59
header : BlockHeader { version : 0x20000000 , prev_blockhash : block. header . block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ,
61
60
txdata : vec ! [ ] ,
62
61
} ;
63
- notifier . block_connected ( & block, i) ;
62
+ connect_block ( node , & block, i) ;
64
63
}
65
64
}
66
65
67
66
pub fn connect_blocks < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , depth : u32 , height : u32 , parent : bool , prev_blockhash : BlockHash ) -> BlockHash {
68
- let notifier = & node. block_notifier ;
69
67
let mut block = Block {
70
68
header : BlockHeader { version : 0x2000000 , prev_blockhash : if parent { prev_blockhash } else { Default :: default ( ) } , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ,
71
69
txdata : vec ! [ ] ,
72
70
} ;
73
- notifier . block_connected ( & block, height + 1 ) ;
71
+ connect_block ( node , & block, height + 1 ) ;
74
72
for i in 2 ..depth + 1 {
75
73
block = Block {
76
74
header : BlockHeader { version : 0x20000000 , prev_blockhash : block. header . block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ,
77
75
txdata : vec ! [ ] ,
78
76
} ;
79
- notifier . block_connected ( & block, height + i) ;
77
+ connect_block ( node , & block, height + i) ;
80
78
}
81
79
block. header . block_hash ( )
82
80
}
83
81
82
+ pub fn connect_block < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , block : & Block , height : u32 ) {
83
+ node. block_notifier . block_connected ( block, height)
84
+ }
85
+
86
+ pub fn disconnect_block < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , header : & BlockHeader , height : u32 ) {
87
+ node. block_notifier . block_disconnected ( header, height)
88
+ }
89
+
84
90
pub struct TestChanMonCfg {
85
91
pub tx_broadcaster : test_utils:: TestBroadcaster ,
86
92
pub fee_estimator : test_utils:: TestFeeEstimator ,
0 commit comments