File tree 3 files changed +12
-4
lines changed
crates/nostr-relay-pool/src/pool 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 58
58
* nostr: add ` Request::multi_pay_invoice ` constructor ([ Yuki Kishimoto] )
59
59
* nostr: add ` Jsonutil::as_pretty_json ` and ` JsonUtil::try_as_pretty_json ` methods ([ Yuki Kishimoto] )
60
60
* pool: add ` RelayPoolNotification::Authenticated ` variant ([ Yuki Kishimoto] )
61
+ * pool: add ` RelayPool::save_subscription ` ([ Yuki Kishimoto] )
61
62
* sdk: add ` Client::gift_wrap_to ` and ` Client::send_private_msg_to ` ([ reyamir] )
62
63
* sdk: add option to autoconnect relay on ` Client::add_relay ` method call ([ Yuki Kishimoto] )
63
64
* sdk: add support to embedded tor client ([ Yuki Kishimoto] )
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ impl InternalRelayPool {
122
122
subscriptions. get ( id) . cloned ( )
123
123
}
124
124
125
- async fn update_pool_subscription ( & self , id : SubscriptionId , filters : Vec < Filter > ) {
125
+ pub async fn save_subscription ( & self , id : SubscriptionId , filters : Vec < Filter > ) {
126
126
let mut subscriptions = self . subscriptions . write ( ) . await ;
127
127
let current: & mut Vec < Filter > = subscriptions. entry ( id) . or_default ( ) ;
128
128
* current = filters;
@@ -459,9 +459,8 @@ impl InternalRelayPool {
459
459
) -> Result < Output < ( ) > , Error > {
460
460
// Check if isn't auto-closing subscription
461
461
if !opts. is_auto_closing ( ) {
462
- // Update pool subscriptions
463
- self . update_pool_subscription ( id. clone ( ) , filters. clone ( ) )
464
- . await ;
462
+ // Save subscription
463
+ self . save_subscription ( id. clone ( ) , filters. clone ( ) ) . await ;
465
464
}
466
465
467
466
// Get relays
Original file line number Diff line number Diff line change @@ -217,6 +217,14 @@ impl RelayPool {
217
217
self . inner . subscription ( id) . await
218
218
}
219
219
220
+ /// Register subscription in the [RelayPool]
221
+ ///
222
+ /// When a new relay will be added, saved subscriptions will be automatically used for it.
223
+ #[ inline]
224
+ pub async fn save_subscription ( & self , id : SubscriptionId , filters : Vec < Filter > ) {
225
+ self . inner . save_subscription ( id, filters) . await
226
+ }
227
+
220
228
/// Send client message to all connected relays
221
229
#[ inline]
222
230
pub async fn send_msg (
You can’t perform that action at this time.
0 commit comments