@@ -274,6 +274,25 @@ lazy_static! {
274
274
#[ cfg( any( test, feature = "testing" ) ) ]
275
275
pub static TEST_PROCESS_BLOCK_STALL : std:: sync:: Mutex < Option < bool > > = std:: sync:: Mutex :: new ( None ) ;
276
276
277
+ fn stall_block_processing ( ) {
278
+ if * TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) == Some ( true ) {
279
+ // Do an extra check just so we don't log EVERY time.
280
+ warn ! ( "Block processing is stalled due to testing directive." ) ;
281
+ while * TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) == Some ( true ) {
282
+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
283
+ }
284
+ info ! ( "Block processing is no longer stalled due to testing directive." ) ;
285
+ }
286
+ }
287
+
288
+ pub fn enable_process_block_stall ( ) {
289
+ TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) . replace ( true ) ;
290
+ }
291
+
292
+ pub fn disable_process_block_stall ( ) {
293
+ TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) . replace ( false ) ;
294
+ }
295
+
277
296
/// Trait for common MARF getters between StacksDBConn and StacksDBTx
278
297
pub trait StacksDBIndexed {
279
298
fn get ( & mut self , tip : & StacksBlockId , key : & str ) -> Result < Option < String > , DBError > ;
@@ -1727,16 +1746,8 @@ impl NakamotoChainState {
1727
1746
dispatcher_opt : Option < & ' a T > ,
1728
1747
) -> Result < Option < StacksEpochReceipt > , ChainstateError > {
1729
1748
#[ cfg( any( test, feature = "testing" ) ) ]
1730
- {
1731
- if * TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) == Some ( true ) {
1732
- // Do an extra check just so we don't log EVERY time.
1733
- warn ! ( "Block processing is stalled due to testing directive." ) ;
1734
- while * TEST_PROCESS_BLOCK_STALL . lock ( ) . unwrap ( ) == Some ( true ) {
1735
- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
1736
- }
1737
- info ! ( "Block processing is no longer stalled due to testing directive." ) ;
1738
- }
1739
- }
1749
+ stall_block_processing ( ) ;
1750
+
1740
1751
let nakamoto_blocks_db = stacks_chain_state. nakamoto_blocks_db ( ) ;
1741
1752
let Some ( ( next_ready_block, block_size) ) =
1742
1753
nakamoto_blocks_db. next_ready_nakamoto_block ( stacks_chain_state. db ( ) ) ?
0 commit comments