WIP: start work on http tracker

This commit is contained in:
Joakim Frostegård 2020-07-01 18:56:19 +02:00
parent ebe4d4357b
commit 404e528616
15 changed files with 1845 additions and 0 deletions

View file

@ -0,0 +1,28 @@
use std::time::Instant;
use crate::common::*;
// identical to ws version
pub fn clean_torrents(state: &State){
fn clean_torrent_map(
torrent_map: &mut TorrentMap,
){
let now = Instant::now();
torrent_map.retain(|_, torrent_data| {
torrent_data.peers.retain(|_, peer| {
peer.valid_until.0 >= now
});
!torrent_data.peers.is_empty()
});
torrent_map.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);
}