From e166dc17ef4c23d52f471cc8883414804a9f1f70 Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Thu, 17 Oct 2024 20:26:12 -0700 Subject: [PATCH] Skip adding relays that are already in the pool --- enostr/src/relay/pool.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/enostr/src/relay/pool.rs b/enostr/src/relay/pool.rs index f4aab0c..30963c9 100644 --- a/enostr/src/relay/pool.rs +++ b/enostr/src/relay/pool.rs @@ -152,6 +152,10 @@ impl RelayPool { url: String, wakeup: impl Fn() + Send + Sync + Clone + 'static, ) -> Result<()> { + // Check if the URL already exists in the pool. + if self.has(&url) { + return Ok(()); + } let relay = Relay::new(url, wakeup)?; let pool_relay = PoolRelay::new(relay);