aquatic: handlers: minor syntax and comment improvements

This commit is contained in:
Joakim Frostegård 2020-04-14 20:13:12 +02:00
parent 6fca5cd9d5
commit 4127cbc7c9

View file

@ -221,14 +221,12 @@ pub fn handle_announce_requests(
.or_default(); .or_default();
let opt_removed_peer_status = if peer_status == PeerStatus::Stopped { let opt_removed_peer_status = if peer_status == PeerStatus::Stopped {
torrent_data.peers.remove(&peer_key) torrent_data.peers.remove(&peer_key).map(|peer| peer.status)
.map(|peer| peer.status)
} else { } else {
torrent_data.peers.insert(peer_key, peer) torrent_data.peers.insert(peer_key, peer).map(|peer| peer.status)
.map(|peer| peer.status)
}; };
let max_num_peers_to_take = calc_number_of_peers_to_take( let max_num_peers_to_take = calc_max_num_peers_to_take(
config, config,
request.peers_wanted.0 request.peers_wanted.0
); );
@ -308,7 +306,7 @@ pub fn handle_scrape_requests(
/// Extract response peers /// Extract response peers
/// ///
/// If there are more peers in map that `number_of_peers_to_take`, do a /// If there are more peers in map than `max_num_peers_to_take`, do a
/// half-random selection of peers from first and second halves of map, /// half-random selection of peers from first and second halves of map,
/// in order to avoid returning too homogeneous peers. /// in order to avoid returning too homogeneous peers.
/// ///
@ -362,7 +360,7 @@ pub fn extract_response_peers(
#[inline] #[inline]
fn calc_number_of_peers_to_take( fn calc_max_num_peers_to_take(
config: &Config, config: &Config,
peers_wanted: i32, peers_wanted: i32,
) -> usize { ) -> usize {