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