Skip to content

Commit

Permalink
Add a heuristic time delay on the estimated time remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu committed Oct 16, 2022
1 parent 9490cb6 commit 336d164
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion snarkos/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,11 @@ impl<N: Network> Ledger<N> {
let height = block.height();
// Compute the percentage completed.
let percentage = height * 100 / latest_height;
// Compute the heuristic slowdown factor (in millis).
let slowdown = (100 * (latest_height - height)) as u128;
// Compute the time remaining (in millis).
let millis_per_block = (timer.elapsed().as_millis()) / (height - ledger_height) as u128;
let time_remaining = (latest_height - height) as u128 * millis_per_block;
let time_remaining = (latest_height - height) as u128 * millis_per_block + slowdown;
// Prepare the estimate message (in secs).
let estimate = format!("(est. {} minutes remaining)", time_remaining / (60 * 1000));
// Log the progress.
Expand Down

0 comments on commit 336d164

Please sign in to comment.