mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
hosts: make quarantine_limit a configurable setting
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user