From 9ee7714cb0cae33ebca6c541af2abc05ac6d71f1 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Wed, 11 Apr 2018 16:24:56 +0300 Subject: [PATCH] Use simple progress bar for indexing --- Cargo.toml | 1 + src/main.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 38cd2d9..56433bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ bitcoin = "0.12" byteorder = "1.2.2" itertools = "0.7.8" log = "0.4" +pbr = "1.0.0" reqwest = "0.8.5" rocksdb = "0.10.0" #{ path = "../../rust-rocksdb" } rust-crypto = "^0.2" diff --git a/src/main.rs b/src/main.rs index 9e03c25..249f6af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ extern crate bitcoin; extern crate byteorder; extern crate crypto; extern crate itertools; +extern crate pbr; extern crate reqwest; extern crate rocksdb; extern crate simple_logger; @@ -106,14 +107,13 @@ fn index_blocks(store: &mut Store) { if hashes.is_empty() { return; } - info!("indexing {} blocks", hashes.len()); - let mut timer = Timer::new(); let mut blocks_size = 0usize; let mut rows_size = 0usize; let mut num_of_rows = 0usize; + let mut pb = pbr::ProgressBar::new(hashes.len() as u64); for (height, blockhash) in hashes { timer.start("get"); let buf: Bytes = daemon::get_bin(&format!("block/{}.bin", &blockhash)); @@ -135,6 +135,7 @@ fn index_blocks(store: &mut Store) { timer.stop(); blocks_size += buf.len(); + pb.inc(); debug!( "{} @ {}: {:.3}/{:.3} MB, {} rows, {}", blockhash, @@ -146,6 +147,7 @@ fn index_blocks(store: &mut Store) { ); } store.flush(); + pb.finish(); } fn main() {