Skip to content

Commit 6399f65

Browse files
committed
Expose remove relay methods for Client
1 parent 85df5b6 commit 6399f65

File tree

5 files changed

+645
-182
lines changed

5 files changed

+645
-182
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* Expose `UnsignedEvent` ([Yuki Kishimoto])
4343
* Expose `EventBuilder` ([Yuki Kishimoto])
4444
* Expose add relay method for `Client` ([Yuki Kishimoto])
45+
* Expose remove relay methods for `Client` ([Yuki Kishimoto])
4546
* Expose `Client::send_event_builder` ([Yuki Kishimoto])
4647
* Expose `Client::automatic_authentication` ([Yuki Kishimoto])
4748
* Expose `Client::reset` ([Yuki Kishimoto])

lib/src/rust/api/client.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,35 @@ abstract class Client implements RustOpaqueInterface {
5858
/// Connect to all added relays
5959
Future<void> connect();
6060

61+
/// Disconnect and force remove all relays
62+
Future<void> forceRemoveAllRelays();
63+
64+
/// Force remove and disconnect relay
65+
///
66+
/// Note: this method will remove the relay, also if it's in use for the gossip model or other service!
67+
Future<void> forceRemoveRelay({required String url});
68+
6169
/// Check if signer is configured
6270
Future<bool> hasSigner();
6371

6472
factory Client() => NostrSdk.instance.api.crateApiClientClientNew();
6573

74+
/// Disconnect and remove all relays
75+
///
76+
/// Some relays used by some services could not be disconnected with this method
77+
/// (like the ones used for gossip).
78+
/// Use [`Client::force_remove_all_relays`] to remove every relay.
79+
Future<void> removeAllRelays();
80+
81+
/// Remove and disconnect relay
82+
///
83+
/// If the relay has [`RelayServiceFlags::GOSSIP`], it will not be removed from the pool and its
84+
/// flags will be updated (remove [`RelayServiceFlags::READ`],
85+
/// [`RelayServiceFlags::WRITE`] and [`RelayServiceFlags::DISCOVERY`] flags).
86+
///
87+
/// To force remove the relay, use [`Client::force_remove_relay`].
88+
Future<void> removeRelay({required String url});
89+
6690
/// Reset client
6791
///
6892
/// This method reset the client to simplify the switch to another account.

0 commit comments

Comments
 (0)