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