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() {