mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
Merge pull request #91 from greatest-ape/work-2022-09-18_2
udp: fix num_seeders/num_leechers counting error, remove some casts; improve shell scripts
This commit is contained in:
commit
3dcf53e0eb
10 changed files with 15 additions and 15 deletions
|
|
@ -136,11 +136,11 @@ fn handle_announce_request<I: Ip>(
|
|||
peer_ip: I,
|
||||
peer_valid_until: ValidUntil,
|
||||
) -> AnnounceResponse<I> {
|
||||
let max_num_peers_to_take = if request.peers_wanted.0 <= 0 {
|
||||
config.protocol.max_response_peers as usize
|
||||
let max_num_peers_to_take: usize = if request.peers_wanted.0 <= 0 {
|
||||
config.protocol.max_response_peers
|
||||
} else {
|
||||
::std::cmp::min(
|
||||
config.protocol.max_response_peers as usize,
|
||||
config.protocol.max_response_peers,
|
||||
request.peers_wanted.0.try_into().unwrap(),
|
||||
)
|
||||
};
|
||||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ impl<I: Ip> TorrentData<I> {
|
|||
|
||||
match opt_removed_peer.map(|peer| peer.is_seeder) {
|
||||
Some(true) => {
|
||||
self.num_leechers -= 1;
|
||||
self.num_seeders -= 1;
|
||||
}
|
||||
Some(false) => {
|
||||
self.num_seeders -= 1;
|
||||
self.num_leechers -= 1;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --release --bin aquatic_udp_bench -- $@
|
||||
cargo run --release -p aquatic_udp_bench -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_http_private -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_http_private -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_http -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_http -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_udp -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_udp -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_ws -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_ws -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_http_load_test -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_http_load_test -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_udp_load_test -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_udp_load_test -- $@
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
. ./scripts/env-native-cpu-without-avx-512
|
||||
|
||||
cargo run --profile "release-debug" --bin aquatic_ws_load_test -- $@
|
||||
cargo run --profile "release-debug" -p aquatic_ws_load_test -- $@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue