Skip to content

Commit a1004ad

Browse files
committed
add info level progress messages
1 parent f1823d8 commit a1004ad

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

src/daemon.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,16 @@ impl Daemon {
768768
let chunk_size = 100_000;
769769
let mut result = vec![];
770770
for heights in all_heights.chunks(chunk_size) {
771-
trace!("downloading {} block headers", heights.len());
772771
let mut headers = self.getblockheaders(&heights)?;
773772
assert!(headers.len() == heights.len());
773+
774774
result.append(&mut headers);
775+
776+
info!("downloaded {}/{} block headers ({:.0}%)",
777+
result.len(),
778+
tip_height,
779+
result.len() as f32 / tip_height as f32 * 100.0);
780+
775781
}
776782

777783
let mut blockhash = *DEFAULT_BLOCKHASH;
@@ -792,7 +798,7 @@ impl Daemon {
792798
) -> Result<Vec<BlockHeader>> {
793799
// Iterate back over headers until known blockash is found:
794800
if indexed_headers.is_empty() {
795-
debug!("downloading all block headers up to {}", bestblockhash);
801+
info!("downloading all block headers up to {}", bestblockhash);
796802
return self.get_all_headers(bestblockhash);
797803
}
798804
debug!(

src/new_index/fetch.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,20 @@ fn bitcoind_fetcher(
8484
Ok(Fetcher::from(
8585
chan.into_receiver(),
8686
spawn_thread("bitcoind_fetcher", move || {
87+
let mut fetcher_count = 0;
88+
let mut blocks_fetched = 0;
89+
let total_blocks_fetched = new_headers.len();
8790
for entries in new_headers.chunks(100) {
91+
if fetcher_count % 50 == 0 && total_blocks_fetched >= 50 {
92+
info!("fetching blocks {}/{} ({:.1}%)",
93+
blocks_fetched,
94+
total_blocks_fetched,
95+
blocks_fetched as f32 / total_blocks_fetched as f32 * 100.0
96+
);
97+
}
98+
fetcher_count += 1;
99+
blocks_fetched += entries.len();
100+
88101
let blockhashes: Vec<BlockHash> = entries.iter().map(|e| *e.hash()).collect();
89102
let blocks = daemon
90103
.getblocks(&blockhashes)
@@ -129,9 +142,17 @@ fn blkfiles_fetcher(
129142
chan.into_receiver(),
130143
spawn_thread("blkfiles_fetcher", move || {
131144
parser.map(|sizedblocks| {
145+
let block_count = sizedblocks.len();
146+
let mut index = 0;
132147
let block_entries: Vec<BlockEntry> = sizedblocks
133148
.into_iter()
134149
.filter_map(|(block, size)| {
150+
index += 1;
151+
debug!("fetch block {:}/{:} {:.2}%",
152+
index,
153+
block_count,
154+
(index/block_count) as f32/100.0
155+
);
135156
let blockhash = block.block_hash();
136157
entry_map
137158
.remove(&blockhash)
@@ -165,7 +186,16 @@ fn blkfiles_reader(blk_files: Vec<PathBuf>, xor_key: Option<[u8; 8]>) -> Fetcher
165186
Fetcher::from(
166187
chan.into_receiver(),
167188
spawn_thread("blkfiles_reader", move || {
189+
let mut count = 0;
190+
let blk_files_len = blk_files.len();
168191
for path in blk_files {
192+
count += 1;
193+
info!("block file reading {:}/{:} {:.2}%",
194+
count,
195+
blk_files_len,
196+
count / blk_files_len
197+
);
198+
169199
trace!("reading {:?}", path);
170200
let mut blob = fs::read(&path)
171201
.unwrap_or_else(|e| panic!("failed to read {:?}: {:?}", path, e));

src/new_index/schema.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,26 @@ impl Indexer {
281281
to_add.len(),
282282
self.from
283283
);
284-
start_fetcher(self.from, &daemon, to_add)?.map(|blocks| self.add(&blocks));
284+
285+
let mut fetcher_count = 0;
286+
let mut blocks_fetched = 0;
287+
let to_add_total = to_add.len();
288+
289+
start_fetcher(self.from, &daemon, to_add)?.map(|blocks|
290+
{
291+
if fetcher_count % 25 == 0 && to_add_total > 20 {
292+
info!("adding txes from blocks {}/{} ({:.1}%)",
293+
blocks_fetched,
294+
to_add_total,
295+
blocks_fetched as f32 / to_add_total as f32 * 100.0
296+
);
297+
}
298+
fetcher_count += 1;
299+
blocks_fetched += blocks.len();
300+
301+
self.add(&blocks)
302+
});
303+
285304
self.start_auto_compactions(&self.store.txstore_db);
286305

287306
let to_index = self.headers_to_index(&new_headers);

0 commit comments

Comments
 (0)