Skip to content

Commit 1226d69

Browse files
committed
use enumerate when iterating to track index and item
1 parent d1da1b2 commit 1226d69

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/new_index/fetch.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,16 @@ fn bitcoind_fetcher(
8484
Ok(Fetcher::from(
8585
chan.into_receiver(),
8686
spawn_thread("bitcoind_fetcher", move || {
87-
let mut fetcher_count = 0;
8887
let mut blocks_fetched = 0;
8988
let total_blocks_fetched = new_headers.len();
90-
for entries in new_headers.chunks(100) {
89+
for (fetcher_count, entries) in new_headers.chunks(100).enumerate() {
9190
if fetcher_count % 50 == 0 && total_blocks_fetched >= 50 {
9291
info!("fetching blocks {}/{} ({:.1}%)",
9392
blocks_fetched,
9493
total_blocks_fetched,
9594
blocks_fetched as f32 / total_blocks_fetched as f32 * 100.0
9695
);
9796
}
98-
fetcher_count += 1;
9997
blocks_fetched += entries.len();
10098

10199
let blockhashes: Vec<BlockHash> = entries.iter().map(|e| *e.hash()).collect();
@@ -186,10 +184,8 @@ fn blkfiles_reader(blk_files: Vec<PathBuf>, xor_key: Option<[u8; 8]>) -> Fetcher
186184
Fetcher::from(
187185
chan.into_receiver(),
188186
spawn_thread("blkfiles_reader", move || {
189-
let mut count = 0;
190187
let blk_files_len = blk_files.len();
191-
for path in blk_files {
192-
count += 1;
188+
for (count, path) in blk_files.iter().enumerate() {
193189
info!("block file reading {:}/{:} {:.2}%",
194190
count,
195191
blk_files_len,

0 commit comments

Comments
 (0)