mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
WIP: start work on http tracker
This commit is contained in:
parent
ebe4d4357b
commit
404e528616
15 changed files with 1845 additions and 0 deletions
28
aquatic_http/src/lib/tasks.rs
Normal file
28
aquatic_http/src/lib/tasks.rs
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue