@@ -196,6 +196,9 @@ pub enum ConnectStyle {
196
196
/// Provides the full block via the `chain::Listen` interface. In the current code this is
197
197
/// equivalent to `TransactionsFirst` with some additional assertions.
198
198
FullBlockViaListen ,
199
+ /// Provides the full block via the `chain::Listen` interface, condensing multiple block
200
+ /// disconnections into a single `blocks_disconnected` call.
201
+ FullBlockDisconnectionsSkippingViaListen ,
199
202
}
200
203
201
204
impl ConnectStyle {
@@ -210,6 +213,7 @@ impl ConnectStyle {
210
213
ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => true ,
211
214
ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
212
215
ConnectStyle :: FullBlockViaListen => false ,
216
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
213
217
}
214
218
}
215
219
@@ -224,14 +228,15 @@ impl ConnectStyle {
224
228
ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => false ,
225
229
ConnectStyle :: TransactionsFirstReorgsOnlyTip => false ,
226
230
ConnectStyle :: FullBlockViaListen => false ,
231
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
227
232
}
228
233
}
229
234
230
235
fn random_style ( ) -> ConnectStyle {
231
236
use core:: hash:: { BuildHasher , Hasher } ;
232
237
// Get a random value using the only std API to do so - the DefaultHasher
233
238
let rand_val = std:: collections:: hash_map:: RandomState :: new ( ) . build_hasher ( ) . finish ( ) ;
234
- let res = match rand_val % 9 {
239
+ let res = match rand_val % 10 {
235
240
0 => ConnectStyle :: BestBlockFirst ,
236
241
1 => ConnectStyle :: BestBlockFirstSkippingBlocks ,
237
242
2 => ConnectStyle :: BestBlockFirstReorgsOnlyTip ,
@@ -241,6 +246,7 @@ impl ConnectStyle {
241
246
6 => ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks ,
242
247
7 => ConnectStyle :: TransactionsFirstReorgsOnlyTip ,
243
248
8 => ConnectStyle :: FullBlockViaListen ,
249
+ 9 => ConnectStyle :: FullBlockDisconnectionsSkippingViaListen ,
244
250
_ => unreachable ! ( ) ,
245
251
} ;
246
252
eprintln ! ( "Using Block Connection Style: {:?}" , res) ;
@@ -371,7 +377,8 @@ fn do_connect_block_without_consistency_checks<'a, 'b, 'c, 'd>(
371
377
node. node . transactions_confirmed ( & block. header , & txdata, height) ;
372
378
node. node . best_block_updated ( & block. header , height) ;
373
379
} ,
374
- ConnectStyle :: FullBlockViaListen => {
380
+ ConnectStyle :: FullBlockViaListen
381
+ | ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
375
382
node. chain_monitor . chain_monitor . block_connected ( & block, height) ;
376
383
node. node . block_connected ( & block, height) ;
377
384
} ,
@@ -432,6 +439,13 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
432
439
node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
433
440
Listen :: blocks_disconnected ( node. node , best_block) ;
434
441
} ,
442
+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
443
+ if i == count - 1 {
444
+ let best_block = BestBlock :: new ( orig. 0 . header . prev_blockhash , orig. 1 - 1 ) ;
445
+ node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
446
+ Listen :: blocks_disconnected ( node. node , best_block) ;
447
+ }
448
+ } ,
435
449
ConnectStyle :: BestBlockFirstSkippingBlocks
436
450
| ConnectStyle :: TransactionsFirstSkippingBlocks
437
451
| ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks
0 commit comments