diff --git a/src/net/hosts.rs b/src/net/hosts.rs index 1ff08c9d4..90dabb8cc 100644 --- a/src/net/hosts.rs +++ b/src/net/hosts.rs @@ -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); } diff --git a/src/net/settings.rs b/src/net/settings.rs index 03fc9b904..ab8bc2af7 100644 --- a/src/net/settings.rs +++ b/src/net/settings.rs @@ -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, } impl From for Settings { @@ -174,6 +180,7 @@ impl From 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), } } }