@@ -482,7 +482,9 @@ fn run_app(cli: Cli) -> Result<(), String> {
482482 if let Some ( mnemonic_phrase) = mnemonic {
483483
484484 let reg_message = tc_response. message . clone ( ) ;
485- let mut wallet_deriv_index: u32 = 0 ; // Start at derivation index 0
485+ // Start at derivation index 0 or CLI flag passed in if resuming
486+ let mut wallet_deriv_index: u32 = cli. mnemonic_starting_index ;
487+ let mut first_run = true ;
486488 let mut max_registered_index = None ;
487489 let mut backoff_challenge = Backoff :: new ( 5 , 300 , 2.0 ) ;
488490 let mut backoff_reg = Backoff :: new ( 5 , 300 , 2.0 ) ;
@@ -512,7 +514,7 @@ fn run_app(cli: Cli) -> Result<(), String> {
512514 backoff_challenge. reset ( ) ;
513515
514516 // Reset index only if we saw a new challenge
515- if cli_challenge_ref. is_none ( ) && params. challenge_id != old_challenge_id {
517+ if cli_challenge_ref. is_none ( ) && params. challenge_id != old_challenge_id && first_run == false {
516518 wallet_deriv_index = 0 ;
517519 }
518520
@@ -534,6 +536,7 @@ fn run_app(cli: Cli) -> Result<(), String> {
534536 continue ;
535537 }
536538 } ;
539+ first_run = false ;
537540
538541 // 1. Generate New Key Pair using Mnemonic and Index
539542 let key_pair = cardano:: derive_key_pair_from_mnemonic ( & mnemonic_phrase, cli. mnemonic_account , wallet_deriv_index) ;
@@ -602,8 +605,7 @@ fn run_app(cli: Cli) -> Result<(), String> {
602605 // The outer loop restarts, calling get_challenge_params again.
603606 }
604607 MiningResult :: MiningFailed => {
605- eprintln ! ( "\n ⚠️ Mining cycle failed. Retrying in 1 minute with the SAME index {}." , wallet_deriv_index) ;
606- thread:: sleep ( Duration :: from_secs ( 60 ) ) ;
608+ eprintln ! ( "\n ⚠️ Mining cycle failed. Retrying with the SAME index {}." , wallet_deriv_index) ;
607609 }
608610 }
609611
0 commit comments