@@ -85,20 +85,27 @@ pub enum ConnectStyle {
85
85
/// The same as BestBlockFirst, however when we have multiple blocks to connect, we only
86
86
/// make a single best_block_updated call.
87
87
BestBlockFirstSkippingBlocks ,
88
+ /// Calls transactions_confirmed first, but only when connecting blocks. During disconnection
89
+ /// only `transaction_unconfirmed` is called.
90
+ BestBlockFirstReorgsOnlyTip ,
88
91
/// Calls transactions_confirmed first, detecting transactions in the block before updating the
89
92
/// header and height information.
90
93
TransactionsFirst ,
91
94
/// The same as TransactionsFirst, however when we have multiple blocks to connect, we only
92
95
/// make a single best_block_updated call.
93
96
TransactionsFirstSkippingBlocks ,
97
+ /// Calls best_block_updated first, but only when connecting blocks. During disconnection only
98
+ /// `transaction_unconfirmed` is called.
99
+ TransactionsFirstReorgsOnlyTip ,
94
100
/// Provides the full block via the chain::Listen interface. In the current code this is
95
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