From 0230550ed39938fc15e5dbe51e56ad9eeb9f62f4 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Sun, 7 Apr 2024 15:07:37 +0400 Subject: [PATCH] Fix fetched bytes computation to not account for stolen bytes. --- TODO.md | 6 ++++++ crates/librqbit/src/torrent_state/live/mod.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 5d44f10..b142953 100644 --- a/TODO.md +++ b/TODO.md @@ -79,7 +79,13 @@ refactor: - [x] peers: if finished they are all paused forever, but if we change the list of files, we need to restart them - [x] opened_files: track HAVE progress + - [x] actually track - [x] show in API and UI - [x] refresh when downloading (it doesn't somehow) - [x] on restart, this is not computed, compute + +- [ ] send cancellation to peers who we stole chunks from +- [ ] don't account for stolen pieces in mesuring speed +- [ ] file priority +- [ ] start/end priority pieces per selected file, not per torrent diff --git a/crates/librqbit/src/torrent_state/live/mod.rs b/crates/librqbit/src/torrent_state/live/mod.rs index 037adad..0dddc95 100644 --- a/crates/librqbit/src/torrent_state/live/mod.rs +++ b/crates/librqbit/src/torrent_state/live/mod.rs @@ -1310,12 +1310,6 @@ impl PeerHandler { .fetch_add(piece.block.len() as u64, Ordering::Relaxed); self.counters.fetched_chunks.fetch_add(1, Ordering::Relaxed); - // Global chunk/byte counters. - self.state - .stats - .fetched_bytes - .fetch_add(piece.block.len() as u64, Ordering::Relaxed); - self.state .peers .with_live_mut(self.addr, "inflight_requests.remove", |h| { @@ -1401,6 +1395,12 @@ impl PeerHandler { } } + // Global chunk/byte counters. + self.state + .stats + .fetched_bytes + .fetch_add(piece.block.len() as u64, Ordering::Relaxed); + let full_piece_download_time = match full_piece_download_time { Some(t) => t, None => return Ok(()),