mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
http: if PeerStatus is Stopped, return empty peer list
This commit is contained in:
parent
ed98327e1a
commit
69c395a702
1 changed files with 15 additions and 11 deletions
|
|
@ -386,18 +386,22 @@ pub fn upsert_peer_and_get_response_peers<I: Ip>(
|
|||
|
||||
::log::debug!("peer request numwant: {:?}", request.numwant);
|
||||
|
||||
let max_num_peers_to_take = match request.numwant {
|
||||
Some(0) | None => config.protocol.max_peers,
|
||||
Some(numwant) => numwant.min(config.protocol.max_peers),
|
||||
};
|
||||
let response_peers = if let PeerStatus::Stopped = peer_status {
|
||||
Vec::new()
|
||||
} else {
|
||||
let max_num_peers_to_take = match request.numwant {
|
||||
Some(0) | None => config.protocol.max_peers,
|
||||
Some(numwant) => numwant.min(config.protocol.max_peers),
|
||||
};
|
||||
|
||||
let response_peers: Vec<ResponsePeer<I>> = extract_response_peers(
|
||||
rng,
|
||||
&torrent_data.peers,
|
||||
max_num_peers_to_take,
|
||||
peer_map_key,
|
||||
Peer::to_response_peer,
|
||||
);
|
||||
extract_response_peers(
|
||||
rng,
|
||||
&torrent_data.peers,
|
||||
max_num_peers_to_take,
|
||||
peer_map_key,
|
||||
Peer::to_response_peer,
|
||||
)
|
||||
};
|
||||
|
||||
(
|
||||
torrent_data.num_seeders,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue