mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
aquatic_udp: use const for empty scrape statistics
This commit is contained in:
parent
32113ea2f3
commit
eafb88c345
1 changed files with 4 additions and 4 deletions
|
|
@ -141,7 +141,7 @@ pub fn handle_scrape_request(
|
||||||
src: SocketAddr,
|
src: SocketAddr,
|
||||||
request: ScrapeRequest,
|
request: ScrapeRequest,
|
||||||
) -> ScrapeResponse {
|
) -> ScrapeResponse {
|
||||||
let empty_stats = create_torrent_scrape_statistics(0, 0);
|
const EMPTY_STATS: TorrentScrapeStatistics = create_torrent_scrape_statistics(0, 0);
|
||||||
|
|
||||||
let mut stats: Vec<TorrentScrapeStatistics> = Vec::with_capacity(request.info_hashes.len());
|
let mut stats: Vec<TorrentScrapeStatistics> = Vec::with_capacity(request.info_hashes.len());
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ pub fn handle_scrape_request(
|
||||||
torrent_data.num_leechers as i32,
|
torrent_data.num_leechers as i32,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
stats.push(empty_stats);
|
stats.push(EMPTY_STATS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -166,7 +166,7 @@ pub fn handle_scrape_request(
|
||||||
torrent_data.num_leechers as i32,
|
torrent_data.num_leechers as i32,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
stats.push(empty_stats);
|
stats.push(EMPTY_STATS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +178,7 @@ pub fn handle_scrape_request(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn create_torrent_scrape_statistics(seeders: i32, leechers: i32) -> TorrentScrapeStatistics {
|
const fn create_torrent_scrape_statistics(seeders: i32, leechers: i32) -> TorrentScrapeStatistics {
|
||||||
TorrentScrapeStatistics {
|
TorrentScrapeStatistics {
|
||||||
seeders: NumberOfPeers(seeders),
|
seeders: NumberOfPeers(seeders),
|
||||||
completed: NumberOfDownloads(0), // No implementation planned
|
completed: NumberOfDownloads(0), // No implementation planned
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue