Skip to content

Commit 7effe41

Browse files
committed
Skip adding relays that are already in the pool
1 parent ea9e1b8 commit 7effe41

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

enostr/src/relay/pool.rs

+4
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ impl RelayPool {
152152
url: String,
153153
wakeup: impl Fn() + Send + Sync + Clone + 'static,
154154
) -> Result<()> {
155+
// Check if the URL already exists in the pool.
156+
if self.has(&url) {
157+
return Ok(());
158+
}
155159
let relay = Relay::new(url, wakeup)?;
156160
let pool_relay = PoolRelay::new(relay);
157161

0 commit comments

Comments
 (0)