@@ -196,6 +196,9 @@ pub enum ConnectStyle {
196196 /// Provides the full block via the `chain::Listen` interface. In the current code this is
197197 /// equivalent to `TransactionsFirst` with some additional assertions.
198198 FullBlockViaListen ,
199+ /// Provides the full block via the `chain::Listen` interface, condensing multiple block
200+ /// disconnections into a single `blocks_disconnected` call.
201+ FullBlockDisconnectionsSkippingViaListen ,
199202}
200203
201204impl ConnectStyle {
@@ -210,6 +213,7 @@ impl ConnectStyle {
210213 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => true ,
211214 ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
212215 ConnectStyle :: FullBlockViaListen => false ,
216+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
213217 }
214218 }
215219
@@ -224,14 +228,15 @@ impl ConnectStyle {
224228 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => false ,
225229 ConnectStyle :: TransactionsFirstReorgsOnlyTip => false ,
226230 ConnectStyle :: FullBlockViaListen => false ,
231+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
227232 }
228233 }
229234
230235 fn random_style ( ) -> ConnectStyle {
231236 use core:: hash:: { BuildHasher , Hasher } ;
232237 // Get a random value using the only std API to do so - the DefaultHasher
233238 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 {
235240 0 => ConnectStyle :: BestBlockFirst ,
236241 1 => ConnectStyle :: BestBlockFirstSkippingBlocks ,
237242 2 => ConnectStyle :: BestBlockFirstReorgsOnlyTip ,
@@ -241,6 +246,7 @@ impl ConnectStyle {
241246 6 => ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks ,
242247 7 => ConnectStyle :: TransactionsFirstReorgsOnlyTip ,
243248 8 => ConnectStyle :: FullBlockViaListen ,
249+ 9 => ConnectStyle :: FullBlockDisconnectionsSkippingViaListen ,
244250 _ => unreachable ! ( ) ,
245251 } ;
246252 eprintln ! ( "Using Block Connection Style: {:?}" , res) ;
@@ -371,7 +377,8 @@ fn do_connect_block_without_consistency_checks<'a, 'b, 'c, 'd>(
371377 node. node . transactions_confirmed ( & block. header , & txdata, height) ;
372378 node. node . best_block_updated ( & block. header , height) ;
373379 } ,
374- ConnectStyle :: FullBlockViaListen => {
380+ ConnectStyle :: FullBlockViaListen
381+ | ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
375382 node. chain_monitor . chain_monitor . block_connected ( & block, height) ;
376383 node. node . block_connected ( & block, height) ;
377384 } ,
@@ -432,6 +439,13 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
432439 node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
433440 Listen :: blocks_disconnected ( node. node , best_block) ;
434441 } ,
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+ } ,
435449 ConnectStyle :: BestBlockFirstSkippingBlocks
436450 | ConnectStyle :: TransactionsFirstSkippingBlocks
437451 | ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks
0 commit comments