1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Refactor blocks' indexing into a separate function

This commit is contained in:
Roman Zeyde 2018-04-10 20:24:22 +03:00
parent e2a610767f
commit e64617fd04
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -288,10 +288,7 @@ impl Store {
}
}
fn main() {
simple_logger::init_with_level(log::Level::Info).unwrap();
let mut store = Store::open("db/mainnet", StoreOptions { auto_compact: true });
fn index_blocks(store: &mut Store) {
let indexed_headers = store.read_headers();
info!("indexed {} headers", indexed_headers.len());
@ -326,17 +323,25 @@ fn main() {
timer.stop();
blocks_size += buf.len();
if height % 100 == 0 {
info!(
"{} @ {}: {:.3}/{:.3} MB, {} rows, {}",
blockhash,
height,
rows_size as f64 / 1e6_f64,
blocks_size as f64 / 1e6_f64,
num_of_rows,
timer.stats()
);
}
debug!(
"{} @ {}: {:.3}/{:.3} MB, {} rows, {}",
blockhash,
height,
rows_size as f64 / 1e6_f64,
blocks_size as f64 / 1e6_f64,
num_of_rows,
timer.stats()
);
}
store.flush();
}
fn main() {
simple_logger::init_with_level(log::Level::Info).unwrap();
let mut store = Store::open("db/mainnet", StoreOptions { auto_compact: true });
index_blocks(&mut store);
// info!("starting full compaction");
// store.db.compact_range(None, None);
// info!("finisged full compaction");
}