udp: handle_announce_request: don't cast usize to i32, use try_into

This commit is contained in:
Joakim Frostegård 2022-09-18 18:06:31 +02:00
parent 8beb13db29
commit 5889cb22f7

View file

@ -163,8 +163,8 @@ fn handle_announce_request<I: Ip>(
AnnounceResponse {
transaction_id: request.transaction_id,
announce_interval: AnnounceInterval(config.protocol.peer_announce_interval),
leechers: NumberOfPeers(torrent_data.num_leechers() as i32),
seeders: NumberOfPeers(torrent_data.num_seeders() as i32),
leechers: NumberOfPeers(torrent_data.num_leechers().try_into().unwrap_or(i32::MAX)),
seeders: NumberOfPeers(torrent_data.num_seeders().try_into().unwrap_or(i32::MAX)),
peers: response_peers,
}
}