diff --git a/crates/nostr-relay-pool/src/pool/inner.rs b/crates/nostr-relay-pool/src/pool/inner.rs index c481ae7cf..0874bc81d 100644 --- a/crates/nostr-relay-pool/src/pool/inner.rs +++ b/crates/nostr-relay-pool/src/pool/inner.rs @@ -224,7 +224,7 @@ impl InnerRelayPool { } // Compose new relay - let relay = Relay::internal_custom(url, self.state.clone(), opts); + let relay: Relay = Relay::internal_custom(url, self.state.clone(), opts); // Set notification sender relay @@ -245,17 +245,13 @@ impl InnerRelayPool { Ok(true) } - pub async fn get_or_add_relay( + pub async fn get_or_add_relay( &self, - url: U, + url: RelayUrl, inherit_pool_subscriptions: bool, opts: RelayOptions, - ) -> Result, Error> - where - U: TryIntoUrl + Clone, - Error: From<::Err>, - { - match self.relay(url.clone()).await { + ) -> Result, Error> { + match self.relay(&url).await { Ok(relay) => Ok(Some(relay)), Err(..) => { self.add_relay(url, inherit_pool_subscriptions, opts) diff --git a/crates/nostr-relay-pool/src/pool/mod.rs b/crates/nostr-relay-pool/src/pool/mod.rs index 3422264a4..6843137bf 100644 --- a/crates/nostr-relay-pool/src/pool/mod.rs +++ b/crates/nostr-relay-pool/src/pool/mod.rs @@ -181,20 +181,18 @@ impl RelayPool { self.inner.add_relay(url, true, opts).await } - /// Try to get relay by `url` or add it to pool. - /// - /// Return `Some(..)` only if the relay already exists. + // Private API + // + // Try to get relay by `url` or add it to pool. + // Return `Some(..)` only if the relay already exists. #[inline] - pub async fn get_or_add_relay( + #[doc(hidden)] + pub async fn __get_or_add_relay( &self, - url: U, + url: RelayUrl, inherit_pool_subscriptions: bool, opts: RelayOptions, - ) -> Result, Error> - where - U: TryIntoUrl + Clone, - Error: From<::Err>, - { + ) -> Result, Error> { self.inner .get_or_add_relay(url, inherit_pool_subscriptions, opts) .await diff --git a/crates/nostr-sdk/src/client/mod.rs b/crates/nostr-sdk/src/client/mod.rs index 520eee65b..129a4a87b 100644 --- a/crates/nostr-sdk/src/client/mod.rs +++ b/crates/nostr-sdk/src/client/mod.rs @@ -394,9 +394,10 @@ impl Client { let opts: RelayOptions = opts.flags(flag); // Add relay with opts or edit current one + // TODO: remove clone here match self .pool - .get_or_add_relay::<&RelayUrl>(&url, inherit_pool_subscriptions, opts) + .__get_or_add_relay(url.clone(), inherit_pool_subscriptions, opts) .await? { Some(relay) => { @@ -404,6 +405,7 @@ impl Client { Ok(false) } None => { + // TODO: move autoconnect to `Relay`? // Connect if `autoconnect` is enabled if self.opts.autoconnect { self.connect_relay::(url).await?;