@@ -171,6 +171,9 @@ pub enum ConnectStyle {
171171 /// Provides the full block via the `chain::Listen` interface. In the current code this is
172172 /// equivalent to `TransactionsFirst` with some additional assertions.
173173 FullBlockViaListen ,
174+ /// Provides the full block via the `chain::Listen` interface, condensing multiple block
175+ /// disconnections into a single `blocks_disconnected` call.
176+ FullBlockDisconnectionsSkippingViaListen ,
174177}
175178
176179impl ConnectStyle {
@@ -185,6 +188,7 @@ impl ConnectStyle {
185188 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => true ,
186189 ConnectStyle :: TransactionsFirstReorgsOnlyTip => true ,
187190 ConnectStyle :: FullBlockViaListen => false ,
191+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
188192 }
189193 }
190194
@@ -199,14 +203,15 @@ impl ConnectStyle {
199203 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks => false ,
200204 ConnectStyle :: TransactionsFirstReorgsOnlyTip => false ,
201205 ConnectStyle :: FullBlockViaListen => false ,
206+ ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => false ,
202207 }
203208 }
204209
205210 fn random_style ( ) -> ConnectStyle {
206211 use core:: hash:: { BuildHasher , Hasher } ;
207212 // Get a random value using the only std API to do so - the DefaultHasher
208213 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 {
210215 0 => ConnectStyle :: BestBlockFirst ,
211216 1 => ConnectStyle :: BestBlockFirstSkippingBlocks ,
212217 2 => ConnectStyle :: BestBlockFirstReorgsOnlyTip ,
@@ -216,6 +221,7 @@ impl ConnectStyle {
216221 6 => ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks ,
217222 7 => ConnectStyle :: TransactionsFirstReorgsOnlyTip ,
218223 8 => ConnectStyle :: FullBlockViaListen ,
224+ 9 => ConnectStyle :: FullBlockDisconnectionsSkippingViaListen ,
219225 _ => unreachable ! ( ) ,
220226 } ;
221227 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
319325 node. node . transactions_confirmed ( & block. header , & txdata, height) ;
320326 node. node . best_block_updated ( & block. header , height) ;
321327 } ,
322- ConnectStyle :: FullBlockViaListen => {
328+ ConnectStyle :: FullBlockViaListen | ConnectStyle :: FullBlockDisconnectionsSkippingViaListen => {
323329 node. chain_monitor . chain_monitor . block_connected ( & block, height) ;
324330 node. node . block_connected ( & block, height) ;
325331 }
@@ -354,6 +360,13 @@ pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32)
354360 node. chain_monitor . chain_monitor . blocks_disconnected ( best_block) ;
355361 Listen :: blocks_disconnected ( node. node , best_block) ;
356362 } ,
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+ } ,
357370 ConnectStyle :: BestBlockFirstSkippingBlocks |ConnectStyle :: TransactionsFirstSkippingBlocks |
358371 ConnectStyle :: HighlyRedundantTransactionsFirstSkippingBlocks |ConnectStyle :: TransactionsDuplicativelyFirstSkippingBlocks => {
359372 if i == count - 1 {
0 commit comments