@@ -171,6 +171,9 @@ pub enum ConnectStyle {
171
171
/// Provides the full block via the `chain::Listen` interface. In the current code this is
172
172
/// equivalent to `TransactionsFirst` with some additional assertions.
173
173
FullBlockViaListen ,
174
+ /// Provides the full block via the `chain::Listen` interface, condensing multiple block
175
+ /// disconnections into a single `blocks_disconnected` call.
176
+ FullBlockDisconnectionsSkippingViaListen ,
174
177
}
175
178
176
179
impl ConnectStyle {
@@ -185,6 +188,7 @@ impl ConnectStyle {
185
188
ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => true ,
186
189
ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
187
190
ConnectStyle :: FullBlockViaListen => false ,
191
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
188
192
}
189
193
}
190
194
@@ -199,14 +203,15 @@ impl ConnectStyle {
199
203
ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => false ,
200
204
ConnectStyle :: TransactionsFirstReorgsOnlyTip => false ,
201
205
ConnectStyle :: FullBlockViaListen => false ,
206
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
202
207
}
203
208
}
204
209
205
210
fn random_style ( ) -> ConnectStyle {
206
211
use core:: hash:: { BuildHasher , Hasher } ;
207
212
// Get a random value using the only std API to do so - the DefaultHasher
208
213
let rand_val = std:: collections:: hash_map:: RandomState :: new ( ) . build_hasher ( ) . finish ( ) ;
209
- let res = match rand_val % 9 {
214
+ let res = match rand_val % 10 {
210
215
0 => ConnectStyle :: BestBlockFirst ,
211
216
1 => ConnectStyle :: BestBlockFirstSkippingBlocks ,
212
217
2 => ConnectStyle :: BestBlockFirstReorgsOnlyTip ,
@@ -216,6 +221,7 @@ impl ConnectStyle {
216
221
6 => ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks ,
217
222
7 => ConnectStyle :: TransactionsFirstReorgsOnlyTip ,
218
223
8 => ConnectStyle :: FullBlockViaListen ,
224
+ 9 => ConnectStyle :: FullBlockDisconnectionsSkippingViaListen ,
219
225
_ => unreachable ! ( ) ,
220
226
} ;
221
227
eprintln ! ( "Using Block Connection Style: {:?}" , res) ;
@@ -319,7 +325,7 @@ fn do_connect_block_without_consistency_checks<'a, 'b, 'c, 'd>(node: &'a Node<'b
319
325
node. node . transactions_confirmed ( & block. header , & txdata, height) ;
320
326
node. node . best_block_updated ( & block. header , height) ;
321
327
} ,
322
- ConnectStyle :: FullBlockViaListen => {
328
+ ConnectStyle :: FullBlockViaListen | ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
323
329
node. chain_monitor . chain_monitor . block_connected ( & block, height) ;
324
330
node. node . block_connected ( & block, height) ;
325
331
}
@@ -354,6 +360,13 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
354
360
node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
355
361
Listen :: blocks_disconnected ( node. node , best_block) ;
356
362
} ,
363
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
364
+ if i == count - 1 {
365
+ let best_block = BestBlock :: new ( orig. 0 . header . prev_blockhash , orig. 1 - 1 ) ;
366
+ node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
367
+ Listen :: blocks_disconnected ( node. node , best_block) ;
368
+ }
369
+ } ,
357
370
ConnectStyle :: BestBlockFirstSkippingBlocks |ConnectStyle :: TransactionsFirstSkippingBlocks |
358
371
ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks |ConnectStyle :: TransactionsDuplicativelyFirstSkippingBlocks => {
359
372
if i == count - 1 {
0 commit comments