From 2b3980e40ab91b40a4adb0ea282c2b47b4279763 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Fri, 29 Mar 2024 13:51:09 +0000 Subject: [PATCH] Better ETA --- crates/librqbit/src/torrent_state/live/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/librqbit/src/torrent_state/live/mod.rs b/crates/librqbit/src/torrent_state/live/mod.rs index c0a8ecec..bd080b6b 100644 --- a/crates/librqbit/src/torrent_state/live/mod.rs +++ b/crates/librqbit/src/torrent_state/live/mod.rs @@ -248,10 +248,8 @@ impl TorrentStateLive { let stats = state.stats_snapshot(); let fetched = stats.fetched_bytes; let needed = state.initially_needed(); - // fetched can be too high in theory, so for safety make sure that it doesn't wrap around u64. - let remaining = needed - .wrapping_sub(fetched) - .min(needed - stats.downloaded_and_checked_bytes); + // TODO: this is too coarse. + let remaining = needed - stats.downloaded_and_checked_bytes; state .down_speed_estimator .add_snapshot(fetched, Some(remaining), now);