Skip to content

Commit

Permalink
feat: [torrust#1002] remove inactive peers always
Browse files Browse the repository at this point in the history
even when `remove_peerless_torrents` is disabled.

We should remove peer that haven't announce otherwise we are returning
inactive peers to the clients. That does not affect keeping the torrents
even if they don't have any peer.
  • Loading branch information
josecelano committed Aug 8, 2024
1 parent bd5f4e8 commit 1766587
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,17 @@ impl Tracker {
self.torrents.get_metrics()
}

/// Remove inactive peers and (optionally) peerless torrents
/// Remove inactive peers and (optionally) peerless torrents.
///
/// # Context: Tracker
pub fn cleanup_torrents(&self) {
// If we don't need to remove torrents we will use the faster iter
let current_cutoff = CurrentClock::now_sub(&Duration::from_secs(u64::from(self.config.tracker_policy.max_peer_timeout)))
.unwrap_or_default();

self.torrents.remove_inactive_peers(current_cutoff);

if self.config.tracker_policy.remove_peerless_torrents {
self.torrents.remove_peerless_torrents(&self.config.tracker_policy);
} else {
let current_cutoff =
CurrentClock::now_sub(&Duration::from_secs(u64::from(self.config.tracker_policy.max_peer_timeout)))
.unwrap_or_default();
self.torrents.remove_inactive_peers(current_cutoff);
}
}

Expand Down

0 comments on commit 1766587

Please sign in to comment.