From 00a38fe4d6f2db9221e7a41e8ff304bd136254d1 Mon Sep 17 00:00:00 2001 From: lbeder Date: Sat, 16 Nov 2024 17:25:02 +0000 Subject: [PATCH] Output current checkpoint --- README.md | 1 + src/main.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9cf1c01..5a2bdee 100755 --- a/README.md +++ b/README.md @@ -283,6 +283,7 @@ SlowKey Parameters: ████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░ 5/10 80% (10s) +Current checkpoint: 1/2 Created checkpoint #5 with data hash 0x3c0c7ab8bb2001c1efd67ce049a437c760cf95d4cc2967160b708fb7216d74d1 ``` diff --git a/src/main.rs b/src/main.rs index f4743c3..21f9036 100755 --- a/src/main.rs +++ b/src/main.rs @@ -542,14 +542,14 @@ fn main() { pb.enable_steady_tick(Duration::from_secs(1)); + let checkpoint_count = ((slowkey_opts.iterations - offset) / checkpointing_interval) as u64; + let mut current_checkpoint = 0; let mut cpb: Option = None; if checkpoint.is_some() && checkpointing_interval != 0 { cpb = Some( - mb.add(ProgressBar::new( - ((slowkey_opts.iterations - offset) / checkpointing_interval) as u64, - )) - .with_style(ProgressStyle::with_template("{msg}").unwrap()), + mb.add(ProgressBar::new(checkpoint_count)) + .with_style(ProgressStyle::with_template("{msg}").unwrap()), ); if let Some(ref mut cpb) = &mut cpb { @@ -575,6 +575,8 @@ fn main() { // Create a checkpoint if we've reached the checkpoint interval if checkpointing_interval != 0 && (current_iteration + 1) % checkpointing_interval == 0 { + current_checkpoint += 1; + let prev_data: Option<&[u8]> = if current_iteration == 0 { None } else { Some(&prev_data) }; if let Some(checkpoint) = &mut checkpoint { @@ -585,7 +587,9 @@ fn main() { let hash = Checkpoint::hash_checkpoint(current_iteration, current_data, prev_data); cpb.set_message(format!( - "\nCreated checkpoint #{} with data hash {}", + "\nCurrent checkpoint: {}/{}\nCreated checkpoint #{} with data hash {}", + current_checkpoint, + checkpoint_count, (current_iteration + 1).to_string().cyan(), format!("0x{}", hex::encode(hash)).cyan() ));