@@ -79,26 +79,33 @@ pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &T
79
79
/// The possible ways we may notify a ChannelManager of a new block
80
80
#[ derive( Clone , Copy , PartialEq ) ]
81
81
pub enum ConnectStyle {
82
- /// Calls best_block_updated first, detecting transactions in the block only after receiving the
83
- /// header and height information.
82
+ /// Calls ` best_block_updated` first, detecting transactions in the block only after receiving
83
+ /// the header and height information.
84
84
BestBlockFirst ,
85
- /// The same as BestBlockFirst, however when we have multiple blocks to connect, we only
86
- /// make a single best_block_updated call.
85
+ /// The same as ` BestBlockFirst` , however when we have multiple blocks to connect, we only
86
+ /// make a single ` best_block_updated` call.
87
87
BestBlockFirstSkippingBlocks ,
88
- /// Calls transactions_confirmed first, detecting transactions in the block before updating the
89
- /// header and height information.
88
+ /// The same as `BestBlockFirst` when connecting blocks. During disconnection only
89
+ /// `transaction_unconfirmed` is called.
90
+ BestBlockFirstReorgsOnlyTip ,
91
+ /// Calls `transactions_confirmed` first, detecting transactions in the block before updating
92
+ /// the header and height information.
90
93
TransactionsFirst ,
91
- /// The same as TransactionsFirst, however when we have multiple blocks to connect, we only
92
- /// make a single best_block_updated call.
94
+ /// The same as ` TransactionsFirst` , however when we have multiple blocks to connect, we only
95
+ /// make a single ` best_block_updated` call.
93
96
TransactionsFirstSkippingBlocks ,
94
- /// Provides the full block via the chain::Listen interface. In the current code this is
95
- /// equivalent to TransactionsFirst with some additional assertions.
97
+ /// The same as `TransactionsFirst` when connecting blocks. During disconnection only
98
+ /// `transaction_unconfirmed` is called.
99
+ TransactionsFirstReorgsOnlyTip ,
100
+ /// Provides the full block via the `chain::Listen` interface. In the current code this is
101
+ /// equivalent to `TransactionsFirst` with some additional assertions.
96
102
FullBlockViaListen ,
97
103
}
98
104
99
105
pub fn connect_blocks < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , depth : u32 ) -> BlockHash {
100
106
let skip_intermediaries = match * node. connect_style . borrow ( ) {
101
- ConnectStyle :: BestBlockFirstSkippingBlocks |ConnectStyle :: TransactionsFirstSkippingBlocks => true ,
107
+ ConnectStyle :: BestBlockFirstSkippingBlocks |ConnectStyle :: TransactionsFirstSkippingBlocks |
108
+ ConnectStyle :: BestBlockFirstReorgsOnlyTip |ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
102
109
_ => false ,
103
110
} ;
104
111
@@ -138,14 +145,14 @@ fn do_connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: Block, sk
138
145
if !skip_intermediaries {
139
146
let txdata: Vec < _ > = block. txdata . iter ( ) . enumerate ( ) . collect ( ) ;
140
147
match * node. connect_style . borrow ( ) {
141
- ConnectStyle :: BestBlockFirst |ConnectStyle :: BestBlockFirstSkippingBlocks => {
148
+ ConnectStyle :: BestBlockFirst |ConnectStyle :: BestBlockFirstSkippingBlocks | ConnectStyle :: BestBlockFirstReorgsOnlyTip => {
142
149
node. chain_monitor . chain_monitor . best_block_updated ( & block. header , height) ;
143
150
call_claimable_balances ( node) ;
144
151
node. chain_monitor . chain_monitor . transactions_confirmed ( & block. header , & txdata, height) ;
145
152
node. node . best_block_updated ( & block. header , height) ;
146
153
node. node . transactions_confirmed ( & block. header , & txdata, height) ;
147
154
} ,
148
- ConnectStyle :: TransactionsFirst |ConnectStyle :: TransactionsFirstSkippingBlocks => {
155
+ ConnectStyle :: TransactionsFirst |ConnectStyle :: TransactionsFirstSkippingBlocks | ConnectStyle :: TransactionsFirstReorgsOnlyTip => {
149
156
node. chain_monitor . chain_monitor . transactions_confirmed ( & block. header , & txdata, height) ;
150
157
call_claimable_balances ( node) ;
151
158
node. chain_monitor . chain_monitor . best_block_updated ( & block. header , height) ;
@@ -181,6 +188,12 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
181
188
node. node . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
182
189
}
183
190
} ,
191
+ ConnectStyle :: BestBlockFirstReorgsOnlyTip |ConnectStyle :: TransactionsFirstReorgsOnlyTip => {
192
+ for tx in orig. 0 . txdata {
193
+ node. chain_monitor . chain_monitor . transaction_unconfirmed ( & tx. txid ( ) ) ;
194
+ node. node . transaction_unconfirmed ( & tx. txid ( ) ) ;
195
+ }
196
+ } ,
184
197
_ => {
185
198
node. chain_monitor . chain_monitor . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
186
199
node. node . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
0 commit comments