From 1cc0f3b34c7ff29675d5130a1c17fe5ab7f16ac6 Mon Sep 17 00:00:00 2001 From: murilo ijanc Date: Wed, 25 Mar 2026 22:19:32 -0300 Subject: Add unban() to BanList and expose it on Node Allows callers to clear bans for specific addresses, needed for re-join logic where bootstrap peers may have been banned after transient failures. --- src/banlist.rs | 6 ++++++ src/node.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/banlist.rs b/src/banlist.rs index f01e31a..4827242 100644 --- a/src/banlist.rs +++ b/src/banlist.rs @@ -102,6 +102,12 @@ impl BanList { .retain(|_, e| e.last_failure.elapsed() < self.ban_duration); } + /// Remove a specific ban and its failure history. + pub fn unban(&mut self, addr: &SocketAddr) { + self.bans.remove(addr); + self.failures.remove(addr); + } + /// Number of currently active bans. pub fn ban_count(&self) -> usize { self.bans diff --git a/src/node.rs b/src/node.rs index fef917e..2c3cec9 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1165,6 +1165,11 @@ impl Node { self.peers.len() } + /// Remove a ban for a specific address. + pub fn unban(&mut self, addr: &std::net::SocketAddr) { + self.ban_list.unban(addr); + } + /// Snapshot of metrics counters. pub fn metrics(&self) -> crate::metrics::MetricsSnapshot { self.metrics.snapshot() -- cgit v1.2.3