udp: statistics: show number of peers

This commit is contained in:
Joakim Frostegård 2021-11-19 12:17:39 +01:00
parent 59e95894b9
commit c78716153b
3 changed files with 23 additions and 1 deletions

View file

@ -128,6 +128,14 @@ pub fn run_request_worker(
if now > last_cleaning + cleaning_interval {
torrents.clean(&config, &state.access_list);
if !statistics_update_interval.is_zero() {
let peers_ipv4 = torrents.ipv4.values().map(|t| t.peers.len()).sum();
let peers_ipv6 = torrents.ipv6.values().map(|t| t.peers.len()).sum();
state.statistics.peers_ipv4[worker_index.0].store(peers_ipv4, Ordering::SeqCst);
state.statistics.peers_ipv6[worker_index.0].store(peers_ipv6, Ordering::SeqCst);
}
last_cleaning = now;
}
if !statistics_update_interval.is_zero()