diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b76856e..d7022feac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ * nostr: add `identifier` arg to NIP-51 `EventBuilder` set constructors ([Yuki Kishimoto]) * pool: use per-purpose dedicated relay channels ([Yuki Kishimoto]) * pool: return relay urls to which `messages`/`events` have or not been sent for `send_*` and `batch_*` methods ([Yuki Kishimoto]) +* pool: rename `Relay::terminate` to `Relay::disconnect` ([Yuki Kishimoto]) * ffi(sdk): convert `RelayPool::handle_notifications` method to async/future ([Yuki Kishimoto]) * js: increase max stack size to `0x1E84800` bytes (32 MiB) ([Yuki Kishimoto]) diff --git a/bindings/nostr-sdk-ffi/src/relay/mod.rs b/bindings/nostr-sdk-ffi/src/relay/mod.rs index 916874ae9..74aee099a 100644 --- a/bindings/nostr-sdk-ffi/src/relay/mod.rs +++ b/bindings/nostr-sdk-ffi/src/relay/mod.rs @@ -155,8 +155,8 @@ impl Relay { } /// Disconnect from relay and set status to 'Terminated' - pub async fn terminate(&self) -> Result<()> { - Ok(self.inner.terminate().await?) + pub async fn disconnect(&self) -> Result<()> { + Ok(self.inner.disconnect().await?) } /// Send msg to relay diff --git a/bindings/nostr-sdk-js/src/relay/mod.rs b/bindings/nostr-sdk-js/src/relay/mod.rs index 14316f9fc..9e7f7b7d2 100644 --- a/bindings/nostr-sdk-js/src/relay/mod.rs +++ b/bindings/nostr-sdk-js/src/relay/mod.rs @@ -131,8 +131,8 @@ impl JsRelay { } /// Disconnect from relay and set status to 'Terminated' - pub async fn terminate(&self) -> Result<()> { - self.inner.terminate().await.map_err(into_err) + pub async fn disconnect(&self) -> Result<()> { + self.inner.disconnect().await.map_err(into_err) } /// Send msg to relay diff --git a/crates/nostr-relay-pool/src/pool/internal.rs b/crates/nostr-relay-pool/src/pool/internal.rs index e94810542..04bbfeec1 100644 --- a/crates/nostr-relay-pool/src/pool/internal.rs +++ b/crates/nostr-relay-pool/src/pool/internal.rs @@ -182,14 +182,14 @@ impl InternalRelayPool { let url: Url = url.try_into_url()?; let mut relays = self.relays.write().await; if let Some(relay) = relays.remove(&url) { - relay.terminate().await?; + relay.disconnect().await?; } Ok(()) } pub async fn remove_all_relays(&self) -> Result<(), Error> { let mut relays = self.relays.write().await; for relay in relays.values() { - relay.terminate().await?; + relay.disconnect().await?; } relays.clear(); Ok(()) @@ -692,7 +692,7 @@ impl InternalRelayPool { pub async fn disconnect(&self) -> Result<(), Error> { let relays = self.relays().await; for relay in relays.into_values() { - relay.terminate().await?; + relay.disconnect().await?; } Ok(()) } diff --git a/crates/nostr-relay-pool/src/relay/internal.rs b/crates/nostr-relay-pool/src/relay/internal.rs index a8fc39f10..05abfa588 100644 --- a/crates/nostr-relay-pool/src/relay/internal.rs +++ b/crates/nostr-relay-pool/src/relay/internal.rs @@ -161,8 +161,8 @@ impl AtomicDestroyer for InternalRelay { fn on_destroy(&self) { let relay = self.clone(); let _ = thread::spawn(async move { - if let Err(e) = relay.terminate().await { - tracing::error!("Impossible to shutdown {} relay: {e}", relay.url); + if let Err(e) = relay.disconnect().await { + tracing::error!("Impossible to shutdown '{}': {e}", relay.url); } }); } @@ -963,7 +963,7 @@ impl InternalRelay { } } - pub async fn terminate(&self) -> Result<(), Error> { + pub async fn disconnect(&self) -> Result<(), Error> { self.schedule_for_termination(true); // TODO: remove? if !self.is_disconnected().await { self.channels diff --git a/crates/nostr-relay-pool/src/relay/mod.rs b/crates/nostr-relay-pool/src/relay/mod.rs index cb0195482..f5690a669 100644 --- a/crates/nostr-relay-pool/src/relay/mod.rs +++ b/crates/nostr-relay-pool/src/relay/mod.rs @@ -223,9 +223,8 @@ impl Relay { /// Disconnect from relay and set status to 'Terminated' #[inline] - pub async fn terminate(&self) -> Result<(), Error> { - // TODO: rename to disconnect - self.inner.terminate().await + pub async fn disconnect(&self) -> Result<(), Error> { + self.inner.disconnect().await } /// Send msg to relay diff --git a/crates/nostr-sdk/src/client/mod.rs b/crates/nostr-sdk/src/client/mod.rs index f1012340a..7c271bb5c 100644 --- a/crates/nostr-sdk/src/client/mod.rs +++ b/crates/nostr-sdk/src/client/mod.rs @@ -555,7 +555,7 @@ impl Client { pool::Error: From<::Err>, { let relay = self.relay(url).await?; - relay.terminate().await?; + relay.disconnect().await?; Ok(()) } diff --git a/crates/nwc/src/lib.rs b/crates/nwc/src/lib.rs index 831dee086..0d1e749a7 100644 --- a/crates/nwc/src/lib.rs +++ b/crates/nwc/src/lib.rs @@ -199,7 +199,7 @@ impl NWC { /// Completely shutdown [NWC] client pub async fn shutdown(self) -> Result<(), Error> { - Ok(self.relay.terminate().await?) + Ok(self.relay.disconnect().await?) } }