mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
aquatic_ws: split torrent state by ipv4/ipv6
This commit is contained in:
parent
7430c23ccc
commit
416d61a2b2
4 changed files with 42 additions and 19 deletions
|
|
@ -4,17 +4,24 @@ use crate::common::*;
|
|||
|
||||
|
||||
pub fn clean_torrents(state: &State){
|
||||
let mut torrents = state.torrents.lock();
|
||||
fn clean_torrent_map(
|
||||
torrent_map: &mut TorrentMap,
|
||||
){
|
||||
let now = Instant::now();
|
||||
|
||||
let now = Instant::now();
|
||||
torrent_map.retain(|_, torrent_data| {
|
||||
torrent_data.peers.retain(|_, peer| {
|
||||
peer.valid_until.0 >= now
|
||||
});
|
||||
|
||||
torrents.retain(|_, torrent_data| {
|
||||
torrent_data.peers.retain(|_, peer| {
|
||||
peer.valid_until.0 >= now
|
||||
!torrent_data.peers.is_empty()
|
||||
});
|
||||
|
||||
!torrent_data.peers.is_empty()
|
||||
});
|
||||
torrent_map.shrink_to_fit();
|
||||
}
|
||||
|
||||
torrents.shrink_to_fit();
|
||||
let mut torrent_maps = state.torrent_maps.lock();
|
||||
|
||||
clean_torrent_map(&mut torrent_maps.ipv4);
|
||||
clean_torrent_map(&mut torrent_maps.ipv6);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue