mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
20 lines
No EOL
381 B
Rust
20 lines
No EOL
381 B
Rust
use std::time::Instant;
|
|
|
|
use crate::common::*;
|
|
|
|
|
|
pub fn clean_torrents(state: &State){
|
|
let mut torrents = state.torrents.lock();
|
|
|
|
let now = Instant::now();
|
|
|
|
torrents.retain(|_, torrent_data| {
|
|
torrent_data.peers.retain(|_, peer| {
|
|
peer.valid_until.0 >= now
|
|
});
|
|
|
|
!torrent_data.peers.is_empty()
|
|
});
|
|
|
|
torrents.shrink_to_fit();
|
|
} |