Use simple progress bar for indexing

This commit is contained in:
Roman Zeyde 2018-04-11 16:24:56 +03:00
parent 09d4df49f3
commit 9ee7714cb0
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 5 additions and 2 deletions

View File

@ -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"

View File

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