udp: request workers: improve handle_scrape_request code

This commit is contained in:
Joakim Frostegård 2022-04-16 02:28:03 +02:00
parent b8a74f0724
commit 80171170c8

View file

@ -193,16 +193,18 @@ fn handle_scrape_request<I: Ip>(
.info_hashes .info_hashes
.into_iter() .into_iter()
.map(|(i, info_hash)| { .map(|(i, info_hash)| {
let s = if let Some(torrent_data) = torrents.0.get(&info_hash) { let stats = torrents
create_torrent_scrape_statistics( .0
torrent_data.num_seeders as i32, .get(&info_hash)
torrent_data.num_leechers as i32, .map(|torrent_data| {
) create_torrent_scrape_statistics(
} else { torrent_data.num_seeders as i32,
EMPTY_STATS torrent_data.num_leechers as i32,
}; )
})
.unwrap_or(EMPTY_STATS);
(i, s) (i, stats)
}) })
.collect(); .collect();