Revert "Another attempt to fix bugs"

This reverts commit 2004e7b21f.
This commit is contained in:
Igor Katson 2024-03-29 13:00:38 +00:00
parent 2004e7b21f
commit ecb55ed32a
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 9 additions and 60 deletions

View file

@ -248,10 +248,10 @@ impl TorrentStateLive {
let stats = state.stats_snapshot();
let fetched = stats.fetched_bytes;
let needed = state.initially_needed();
// TODO: this is very coarse, as it doesn't capture partially
// downloaded pieces. But it's better than using "fetched" which is bugged,
// see #92
let remaining = needed - stats.downloaded_and_checked_bytes;
// 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);
state
.down_speed_estimator
.add_snapshot(fetched, Some(remaining), now);