mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic: put max_scrape_torrents, max_response_peers in NetworkConfig
This commit is contained in:
parent
7239e9c047
commit
31c8864658
3 changed files with 6 additions and 6 deletions
|
|
@ -4,8 +4,6 @@ use std::net::SocketAddr;
|
|||
#[derive(Clone)]
|
||||
pub struct Config {
|
||||
pub num_threads: usize,
|
||||
pub max_scrape_torrents: u8,
|
||||
pub max_response_peers: usize,
|
||||
pub network: NetworkConfig,
|
||||
pub statistics: StatisticsConfig,
|
||||
pub cleaning: CleaningConfig,
|
||||
|
|
@ -15,6 +13,8 @@ pub struct Config {
|
|||
#[derive(Clone)]
|
||||
pub struct NetworkConfig {
|
||||
pub address: SocketAddr,
|
||||
pub max_scrape_torrents: u8,
|
||||
pub max_response_peers: usize,
|
||||
pub peer_announce_interval: i32,
|
||||
pub recv_buffer_size: usize,
|
||||
pub poll_event_capacity: usize,
|
||||
|
|
@ -39,8 +39,6 @@ impl Default for Config {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
num_threads: 4,
|
||||
max_scrape_torrents: 255,
|
||||
max_response_peers: 255,
|
||||
network: NetworkConfig::default(),
|
||||
statistics: StatisticsConfig::default(),
|
||||
cleaning: CleaningConfig::default(),
|
||||
|
|
@ -53,6 +51,8 @@ impl Default for NetworkConfig {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
address: SocketAddr::from(([127, 0, 0, 1], 3000)),
|
||||
max_scrape_torrents: 255,
|
||||
max_response_peers: 255,
|
||||
peer_announce_interval: 60 * 15,
|
||||
poll_event_capacity: 4096,
|
||||
recv_buffer_size: 4096 * 128,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ pub fn handle_announce_requests(
|
|||
};
|
||||
|
||||
let max_num_peers_to_take = (request.peers_wanted.0.max(0) as usize)
|
||||
.min(config.max_response_peers);
|
||||
.min(config.network.max_response_peers);
|
||||
|
||||
// Since there is a miniscule risk of the torrent having been removed
|
||||
// by now, don't unwrap the result.
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ fn handle_readable_socket(
|
|||
Ok((amt, src)) => {
|
||||
let request = request_from_bytes(
|
||||
&buffer[..amt],
|
||||
config.max_scrape_torrents
|
||||
config.network.max_scrape_torrents
|
||||
);
|
||||
|
||||
bytes_received += amt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue