safecoin_client/
spinner.rs1use indicatif::{ProgressBar, ProgressStyle};
4
5pub(crate) fn new_progress_bar() -> ProgressBar {
6 let progress_bar = ProgressBar::new(42);
7 progress_bar
8 .set_style(ProgressStyle::default_spinner().template("{spinner:.green} {wide_msg}"));
9 progress_bar.enable_steady_tick(100);
10 progress_bar
11}
12
13pub(crate) fn set_message_for_confirmed_transactions(
14 progress_bar: &ProgressBar,
15 confirmed_transactions: u32,
16 total_transactions: usize,
17 block_height: Option<u64>,
18 last_valid_block_height: u64,
19 status: &str,
20) {
21 progress_bar.set_message(format!(
22 "{:>5.1}% | {:<40}{}",
23 confirmed_transactions as f64 * 100. / total_transactions as f64,
24 status,
25 match block_height {
26 Some(block_height) => format!(
27 " [block height {}; re-sign in {} blocks]",
28 block_height,
29 last_valid_block_height.saturating_sub(block_height),
30 ),
31 None => String::new(),
32 },
33 ));
34}