Skip to content

Commit 7616ec3

Browse files
committed
pool: rename Relay::terminate to Relay::disconnect
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 0ff5770 commit 7616ec3

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* nostr: add `identifier` arg to NIP-51 `EventBuilder` set constructors ([Yuki Kishimoto])
3333
* pool: use per-purpose dedicated relay channels ([Yuki Kishimoto])
3434
* pool: return relay urls to which `messages`/`events` have or not been sent for `send_*` and `batch_*` methods ([Yuki Kishimoto])
35+
* pool: rename `Relay::terminate` to `Relay::disconnect` ([Yuki Kishimoto])
3536
* ffi(sdk): convert `RelayPool::handle_notifications` method to async/future ([Yuki Kishimoto])
3637
* js: increase max stack size to `0x1E84800` bytes (32 MiB) ([Yuki Kishimoto])
3738

bindings/nostr-sdk-ffi/src/relay/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ impl Relay {
155155
}
156156

157157
/// Disconnect from relay and set status to 'Terminated'
158-
pub async fn terminate(&self) -> Result<()> {
159-
Ok(self.inner.terminate().await?)
158+
pub async fn disconnect(&self) -> Result<()> {
159+
Ok(self.inner.disconnect().await?)
160160
}
161161

162162
/// Send msg to relay

bindings/nostr-sdk-js/src/relay/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ impl JsRelay {
131131
}
132132

133133
/// Disconnect from relay and set status to 'Terminated'
134-
pub async fn terminate(&self) -> Result<()> {
135-
self.inner.terminate().await.map_err(into_err)
134+
pub async fn disconnect(&self) -> Result<()> {
135+
self.inner.disconnect().await.map_err(into_err)
136136
}
137137

138138
/// Send msg to relay

crates/nostr-relay-pool/src/pool/internal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ impl InternalRelayPool {
182182
let url: Url = url.try_into_url()?;
183183
let mut relays = self.relays.write().await;
184184
if let Some(relay) = relays.remove(&url) {
185-
relay.terminate().await?;
185+
relay.disconnect().await?;
186186
}
187187
Ok(())
188188
}
189189
pub async fn remove_all_relays(&self) -> Result<(), Error> {
190190
let mut relays = self.relays.write().await;
191191
for relay in relays.values() {
192-
relay.terminate().await?;
192+
relay.disconnect().await?;
193193
}
194194
relays.clear();
195195
Ok(())
@@ -692,7 +692,7 @@ impl InternalRelayPool {
692692
pub async fn disconnect(&self) -> Result<(), Error> {
693693
let relays = self.relays().await;
694694
for relay in relays.into_values() {
695-
relay.terminate().await?;
695+
relay.disconnect().await?;
696696
}
697697
Ok(())
698698
}

crates/nostr-relay-pool/src/relay/internal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ impl AtomicDestroyer for InternalRelay {
161161
fn on_destroy(&self) {
162162
let relay = self.clone();
163163
let _ = thread::spawn(async move {
164-
if let Err(e) = relay.terminate().await {
165-
tracing::error!("Impossible to shutdown {} relay: {e}", relay.url);
164+
if let Err(e) = relay.disconnect().await {
165+
tracing::error!("Impossible to shutdown '{}': {e}", relay.url);
166166
}
167167
});
168168
}
@@ -963,7 +963,7 @@ impl InternalRelay {
963963
}
964964
}
965965

966-
pub async fn terminate(&self) -> Result<(), Error> {
966+
pub async fn disconnect(&self) -> Result<(), Error> {
967967
self.schedule_for_termination(true); // TODO: remove?
968968
if !self.is_disconnected().await {
969969
self.channels

crates/nostr-relay-pool/src/relay/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ impl Relay {
223223

224224
/// Disconnect from relay and set status to 'Terminated'
225225
#[inline]
226-
pub async fn terminate(&self) -> Result<(), Error> {
227-
// TODO: rename to disconnect
228-
self.inner.terminate().await
226+
pub async fn disconnect(&self) -> Result<(), Error> {
227+
self.inner.disconnect().await
229228
}
230229

231230
/// Send msg to relay

crates/nostr-sdk/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl Client {
555555
pool::Error: From<<U as TryIntoUrl>::Err>,
556556
{
557557
let relay = self.relay(url).await?;
558-
relay.terminate().await?;
558+
relay.disconnect().await?;
559559
Ok(())
560560
}
561561

crates/nwc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl NWC {
199199

200200
/// Completely shutdown [NWC] client
201201
pub async fn shutdown(self) -> Result<(), Error> {
202-
Ok(self.relay.terminate().await?)
202+
Ok(self.relay.disconnect().await?)
203203
}
204204
}
205205

0 commit comments

Comments
 (0)