hosts: make quarantine_limit a configurable setting

This commit is contained in:
x
2023-08-24 12:19:17 +02:00
parent 61c269f776
commit a53e84f5ea
2 changed files with 8 additions and 1 deletions

View File

@@ -185,7 +185,7 @@ impl Hosts {
if let Some(retries) = q.get_mut(url) {
*retries += 1;
debug!(target: "net::hosts::quarantine()", "Peer {} quarantined {} times", url, retries);
if *retries == 50 {
if *retries == self.settings.hosts_quarantine_limit {
debug!(target: "net::hosts::quarantine()", "Deleting peer {}", url);
q.remove(url);
}

View File

@@ -59,6 +59,8 @@ pub struct Settings {
pub channel_heartbeat_interval: u64,
/// Allow localnet hosts
pub localnet: bool,
/// Delete a peer from hosts if they've been quarantined N times
pub hosts_quarantine_limit: usize,
}
impl Default for Settings {
@@ -81,6 +83,7 @@ impl Default for Settings {
channel_handshake_timeout: 10,
channel_heartbeat_interval: 10,
localnet: false,
hosts_quarantine_limit: 50,
}
}
}
@@ -152,6 +155,9 @@ pub struct SettingsOpt {
#[serde(default)]
#[structopt(long)]
pub localnet: bool,
#[structopt(skip)]
pub hosts_quarantine_limit: Option<usize>,
}
impl From<SettingsOpt> for Settings {
@@ -174,6 +180,7 @@ impl From<SettingsOpt> for Settings {
channel_handshake_timeout: opt.channel_handshake_timeout.unwrap_or(10),
channel_heartbeat_interval: opt.channel_heartbeat_interval.unwrap_or(10),
localnet: opt.localnet,
hosts_quarantine_limit: opt.hosts_quarantine_limit.unwrap_or(15),
}
}
}