@@ -79,26 +79,33 @@ pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &T
7979/// The possible ways we may notify a ChannelManager of a new block
8080#[ derive( Clone , Copy , PartialEq ) ]
8181pub 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.
8484 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.
8787 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.
9093 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.
9396 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.
96102 FullBlockViaListen ,
97103}
98104
99105pub fn connect_blocks < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , depth : u32 ) -> BlockHash {
100106 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 ,
102109 _ => false ,
103110 } ;
104111
@@ -138,14 +145,14 @@ fn do_connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: Block, sk
138145 if !skip_intermediaries {
139146 let txdata: Vec < _ > = block. txdata . iter ( ) . enumerate ( ) . collect ( ) ;
140147 match * node. connect_style . borrow ( ) {
141- ConnectStyle :: BestBlockFirst |ConnectStyle :: BestBlockFirstSkippingBlocks => {
148+ ConnectStyle :: BestBlockFirst |ConnectStyle :: BestBlockFirstSkippingBlocks | ConnectStyle :: BestBlockFirstReorgsOnlyTip => {
142149 node. chain_monitor . chain_monitor . best_block_updated ( & block. header , height) ;
143150 call_claimable_balances ( node) ;
144151 node. chain_monitor . chain_monitor . transactions_confirmed ( & block. header , & txdata, height) ;
145152 node. node . best_block_updated ( & block. header , height) ;
146153 node. node . transactions_confirmed ( & block. header , & txdata, height) ;
147154 } ,
148- ConnectStyle :: TransactionsFirst |ConnectStyle :: TransactionsFirstSkippingBlocks => {
155+ ConnectStyle :: TransactionsFirst |ConnectStyle :: TransactionsFirstSkippingBlocks | ConnectStyle :: TransactionsFirstReorgsOnlyTip => {
149156 node. chain_monitor . chain_monitor . transactions_confirmed ( & block. header , & txdata, height) ;
150157 call_claimable_balances ( node) ;
151158 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)
181188 node. node . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
182189 }
183190 } ,
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+ } ,
184197 _ => {
185198 node. chain_monitor . chain_monitor . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
186199 node. node . best_block_updated ( & prev. 0 . header , prev. 1 ) ;
0 commit comments