From 029f4eb0d8a54ce6ca0339be0e5602e7e3b70b63 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 11 Apr 2026 22:26:23 -0300 Subject: [PATCH] pool: AddToPenaltyBox() manually. --- pool.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pool.go b/pool.go index 14e5605..892bfaa 100644 --- a/pool.go +++ b/pool.go @@ -118,6 +118,17 @@ func (pool *Pool) StartPenaltyBox() { }() } +// AddToPenaltyBox manually adds a relay to the penalty box for the specified duration. +// This prevents EnsureRelay from attempting to connect to the relay until the duration expires. +func (pool *Pool) AddToPenaltyBox(url string, duration time.Duration) { + if pool.penaltyBox == nil { + return + } + nm := NormalizeURL(url) + pool.penaltyBox.Store(nm, [2]float64{0, duration.Seconds()}) + pool.Relays.Store(nm, nil) // mark as explicitly disconnected for penalty box detection +} + // EnsureRelay ensures that a relay connection exists and is active. // If the relay is not connected, it attempts to connect. func (pool *Pool) EnsureRelay(url string) (*Relay, error) {