aquatic_ws: split torrent state by ipv4/ipv6

This commit is contained in:
Joakim Frostegård 2020-05-23 15:15:01 +02:00
parent 7430c23ccc
commit 416d61a2b2
4 changed files with 42 additions and 19 deletions

View file

@ -83,16 +83,23 @@ impl Default for TorrentData {
pub type TorrentMap = HashMap<InfoHash, TorrentData>;
#[derive(Default)]
pub struct TorrentMaps {
pub ipv4: TorrentMap,
pub ipv6: TorrentMap,
}
#[derive(Clone)]
pub struct State {
pub torrents: Arc<Mutex<TorrentMap>>,
pub torrent_maps: Arc<Mutex<TorrentMaps>>,
}
impl Default for State {
fn default() -> Self {
Self {
torrents: Arc::new(Mutex::new(HashMap::new())),
torrent_maps: Arc::new(Mutex::new(TorrentMaps::default())),
}
}
}