mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
aquatic: announce: fix bug in calculation of number of peers to take
This commit is contained in:
parent
8f68b3a9a2
commit
c44c5b017f
1 changed files with 20 additions and 2 deletions
|
|
@ -228,8 +228,10 @@ pub fn handle_announce_requests(
|
||||||
.map(|peer| peer.status)
|
.map(|peer| peer.status)
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_num_peers_to_take = (request.peers_wanted.0.max(0) as usize)
|
let max_num_peers_to_take = calc_number_of_peers_to_take(
|
||||||
.min(config.network.max_response_peers);
|
config,
|
||||||
|
request.peers_wanted.0
|
||||||
|
);
|
||||||
|
|
||||||
match peer_status {
|
match peer_status {
|
||||||
PeerStatus::Leeching => {
|
PeerStatus::Leeching => {
|
||||||
|
|
@ -359,6 +361,22 @@ pub fn extract_response_peers(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn calc_number_of_peers_to_take(
|
||||||
|
config: &Config,
|
||||||
|
peers_wanted: i32,
|
||||||
|
) -> usize {
|
||||||
|
if peers_wanted <= 0 {
|
||||||
|
config.network.max_response_peers as usize
|
||||||
|
} else {
|
||||||
|
::std::cmp::min(
|
||||||
|
config.network.max_response_peers as usize,
|
||||||
|
peers_wanted as usize
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn create_torrent_scrape_statistics(
|
pub fn create_torrent_scrape_statistics(
|
||||||
seeders: i32,
|
seeders: i32,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue