From 38eb880cee785fa77d10105b4f1332afcef8a255 Mon Sep 17 00:00:00 2001 From: Philippe McLean Date: Tue, 4 Nov 2025 13:49:10 -0800 Subject: [PATCH] add info level progress messages --- src/daemon.rs | 10 ++++++++-- src/new_index/db.rs | 4 ++-- src/new_index/fetch.rs | 30 +++++++++++++++++++++++++++++- src/new_index/schema.rs | 21 ++++++++++++++++++++- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index 211f7d94d..cf381fa8d 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -768,10 +768,16 @@ impl Daemon { let chunk_size = 100_000; let mut result = vec![]; for heights in all_heights.chunks(chunk_size) { - trace!("downloading {} block headers", heights.len()); let mut headers = self.getblockheaders(&heights)?; assert!(headers.len() == heights.len()); + result.append(&mut headers); + + info!("downloaded {}/{} block headers ({:.0}%)", + result.len(), + tip_height, + result.len() as f32 / tip_height as f32 * 100.0); + } let mut blockhash = *DEFAULT_BLOCKHASH; @@ -792,7 +798,7 @@ impl Daemon { ) -> Result> { // Iterate back over headers until known blockash is found: if indexed_headers.is_empty() { - debug!("downloading all block headers up to {}", bestblockhash); + info!("downloading all block headers up to {}", bestblockhash); return self.get_all_headers(bestblockhash); } debug!( diff --git a/src/new_index/db.rs b/src/new_index/db.rs index e889aad63..7527b3f5d 100644 --- a/src/new_index/db.rs +++ b/src/new_index/db.rs @@ -125,9 +125,9 @@ impl DB { pub fn full_compaction(&self) { // TODO: make sure this doesn't fail silently - debug!("starting full compaction on {:?}", self.db); + info!("starting full compaction on {:?}", self.db); self.db.compact_range(None::<&[u8]>, None::<&[u8]>); - debug!("finished full compaction on {:?}", self.db); + info!("finished full compaction on {:?}", self.db); } pub fn enable_auto_compaction(&self) { diff --git a/src/new_index/fetch.rs b/src/new_index/fetch.rs index fd92ffedc..7906fb206 100644 --- a/src/new_index/fetch.rs +++ b/src/new_index/fetch.rs @@ -84,7 +84,20 @@ fn bitcoind_fetcher( Ok(Fetcher::from( chan.into_receiver(), spawn_thread("bitcoind_fetcher", move || { + let mut fetcher_count = 0; + let mut blocks_fetched = 0; + let total_blocks_fetched = new_headers.len(); for entries in new_headers.chunks(100) { + if fetcher_count % 50 == 0 && total_blocks_fetched >= 50 { + info!("fetching blocks {}/{} ({:.1}%)", + blocks_fetched, + total_blocks_fetched, + blocks_fetched as f32 / total_blocks_fetched as f32 * 100.0 + ); + } + fetcher_count += 1; + blocks_fetched += entries.len(); + let blockhashes: Vec = entries.iter().map(|e| *e.hash()).collect(); let blocks = daemon .getblocks(&blockhashes) @@ -129,9 +142,17 @@ fn blkfiles_fetcher( chan.into_receiver(), spawn_thread("blkfiles_fetcher", move || { parser.map(|sizedblocks| { + let block_count = sizedblocks.len(); + let mut index = 0; let block_entries: Vec = sizedblocks .into_iter() .filter_map(|(block, size)| { + index += 1; + debug!("fetch block {:}/{:} {:.2}%", + index, + block_count, + (index/block_count) as f32/100.0 + ); let blockhash = block.block_hash(); entry_map .remove(&blockhash) @@ -165,7 +186,14 @@ fn blkfiles_reader(blk_files: Vec, xor_key: Option<[u8; 8]>) -> Fetcher Fetcher::from( chan.into_receiver(), spawn_thread("blkfiles_reader", move || { - for path in blk_files { + let blk_files_len = blk_files.len(); + for (count, path) in blk_files.iter().enumerate() { + info!("block file reading {:}/{:} {:.2}%", + count, + blk_files_len, + count / blk_files_len + ); + trace!("reading {:?}", path); let mut blob = fs::read(&path) .unwrap_or_else(|e| panic!("failed to read {:?}: {:?}", path, e)); diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index 7fb74e825..c3e96d5d8 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -281,7 +281,26 @@ impl Indexer { to_add.len(), self.from ); - start_fetcher(self.from, &daemon, to_add)?.map(|blocks| self.add(&blocks)); + + let mut fetcher_count = 0; + let mut blocks_fetched = 0; + let to_add_total = to_add.len(); + + start_fetcher(self.from, &daemon, to_add)?.map(|blocks| + { + if fetcher_count % 25 == 0 && to_add_total > 20 { + info!("adding txes from blocks {}/{} ({:.1}%)", + blocks_fetched, + to_add_total, + blocks_fetched as f32 / to_add_total as f32 * 100.0 + ); + } + fetcher_count += 1; + blocks_fetched += blocks.len(); + + self.add(&blocks) + }); + self.start_auto_compactions(&self.store.txstore_db); let to_index = self.headers_to_index(&new_headers);