Fix fetched bytes computation to not account for stolen bytes.

This commit is contained in:
Igor Katson 2024-04-07 15:07:37 +04:00
parent 511e64751c
commit 0230550ed3
2 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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(()),