Skip to content

Commit

Permalink
pool: rename Relay::terminate to Relay::disconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Jun 18, 2024
1 parent 0ff5770 commit 7616ec3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
4 changes: 2 additions & 2 deletions bindings/nostr-sdk-ffi/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bindings/nostr-sdk-js/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/nostr-relay-pool/src/pool/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down Expand Up @@ -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(())
}
Expand Down
6 changes: 3 additions & 3 deletions crates/nostr-relay-pool/src/relay/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions crates/nostr-relay-pool/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl Client {
pool::Error: From<<U as TryIntoUrl>::Err>,
{
let relay = self.relay(url).await?;
relay.terminate().await?;
relay.disconnect().await?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion crates/nwc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
}
}

Expand Down

0 comments on commit 7616ec3

Please sign in to comment.