@@ -197,6 +197,9 @@ pub enum ConnectStyle {
197197 /// Provides the full block via the `chain::Listen` interface. In the current code this is
198198 /// equivalent to `TransactionsFirst` with some additional assertions.
199199 FullBlockViaListen ,
200+ /// Provides the full block via the `chain::Listen` interface, condensing multiple block
201+ /// disconnections into a single `blocks_disconnected` call.
202+ FullBlockDisconnectionsSkippingViaListen ,
200203}
201204
202205impl ConnectStyle {
@@ -211,6 +214,7 @@ impl ConnectStyle {
211214 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => true ,
212215 ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
213216 ConnectStyle :: FullBlockViaListen => false ,
217+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
214218 }
215219 }
216220
@@ -225,14 +229,15 @@ impl ConnectStyle {
225229 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => false ,
226230 ConnectStyle :: TransactionsFirstReorgsOnlyTip => false ,
227231 ConnectStyle :: FullBlockViaListen => false ,
232+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
228233 }
229234 }
230235
231236 fn random_style ( ) -> ConnectStyle {
232237 use core:: hash:: { BuildHasher , Hasher } ;
233238 // Get a random value using the only std API to do so - the DefaultHasher
234239 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 {
236241 0 => ConnectStyle :: BestBlockFirst ,
237242 1 => ConnectStyle :: BestBlockFirstSkippingBlocks ,
238243 2 => ConnectStyle :: BestBlockFirstReorgsOnlyTip ,
@@ -242,6 +247,7 @@ impl ConnectStyle {
242247 6 => ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks ,
243248 7 => ConnectStyle :: TransactionsFirstReorgsOnlyTip ,
244249 8 => ConnectStyle :: FullBlockViaListen ,
250+ 9 => ConnectStyle :: FullBlockDisconnectionsSkippingViaListen ,
245251 _ => unreachable ! ( ) ,
246252 } ;
247253 eprintln ! ( "Using Block Connection Style: {:?}" , res) ;
@@ -372,7 +378,8 @@ fn do_connect_block_without_consistency_checks<'a, 'b, 'c, 'd>(
372378 node. node . transactions_confirmed ( & block. header , & txdata, height) ;
373379 node. node . best_block_updated ( & block. header , height) ;
374380 } ,
375- ConnectStyle :: FullBlockViaListen => {
381+ ConnectStyle :: FullBlockViaListen
382+ | ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
376383 node. chain_monitor . chain_monitor . block_connected ( & block, height) ;
377384 node. node . block_connected ( & block, height) ;
378385 } ,
@@ -433,6 +440,13 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
433440 node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
434441 Listen :: blocks_disconnected ( node. node , best_block) ;
435442 } ,
443+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
444+ if i == count - 1 {
445+ let best_block = BestBlock :: new ( orig. 0 . header . prev_blockhash , orig. 1 - 1 ) ;
446+ node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
447+ Listen :: blocks_disconnected ( node. node , best_block) ;
448+ }
449+ } ,
436450 ConnectStyle :: BestBlockFirstSkippingBlocks
437451 | ConnectStyle :: TransactionsFirstSkippingBlocks
438452 | ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks
0 commit comments