Skip to content

Commit

Permalink
fix: don't double count completed stat when peers announce as complet…
Browse files Browse the repository at this point in the history
…ed multiple times
  • Loading branch information
mickvandijke committed May 16, 2022
1 parent 9ec5ed2 commit 048d35c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tracker/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ impl TorrentEntry {
AnnounceEvent::Completed => {
let peer_old = self.peers.insert(peer.peer_id.clone(), peer.clone());
// Don't count if peer was not previously known
if peer_old.is_some() {
self.completed += 1;
did_torrent_stats_change = true;
if let Some(old_peer) = peer_old {
// Don't double count
if !old_peer.is_seeder() {
self.completed += 1;
did_torrent_stats_change = true;
}
}
}
_ => {
Expand Down

0 comments on commit 048d35c

Please sign in to comment.