@@ -7,7 +7,6 @@ use std::ops::Deref;
7
7
use std:: sync:: Arc ;
8
8
use std:: time:: Duration ;
9
9
10
- use async_utility:: thread;
11
10
use nostr_ffi:: { ClientMessage , Event , EventId , Filter } ;
12
11
use nostr_sdk:: database:: DynNostrDatabase ;
13
12
use nostr_sdk:: { RelayPoolOptions , SubscriptionId } ;
@@ -422,40 +421,33 @@ impl RelayPool {
422
421
}
423
422
424
423
/// Handle relay pool notifications
425
- ///
426
- /// <div class="warning">Python bindings needs to call `uniffi_set_event_loop(asyncio.get_running_loop())` before this method!</div>
427
- pub fn handle_notifications (
428
- self : Arc < Self > ,
429
- handler : Arc < dyn HandleNotification > ,
430
- ) -> Result < ( ) > {
431
- thread:: spawn ( async move {
432
- self . inner
433
- . handle_notifications ( |notification| async {
434
- match notification {
435
- nostr_sdk:: RelayPoolNotification :: Message { relay_url, message } => {
436
- handler
437
- . handle_msg ( relay_url. to_string ( ) , Arc :: new ( message. into ( ) ) )
438
- . await ;
439
- }
440
- nostr_sdk:: RelayPoolNotification :: Event {
441
- relay_url,
442
- subscription_id,
443
- event,
444
- } => {
445
- handler
446
- . handle (
447
- relay_url. to_string ( ) ,
448
- subscription_id. to_string ( ) ,
449
- Arc :: new ( ( * event) . into ( ) ) ,
450
- )
451
- . await ;
452
- }
453
- _ => ( ) ,
424
+ pub async fn handle_notifications ( & self , handler : Arc < dyn HandleNotification > ) -> Result < ( ) > {
425
+ Ok ( self
426
+ . inner
427
+ . handle_notifications ( |notification| async {
428
+ match notification {
429
+ nostr_sdk:: RelayPoolNotification :: Message { relay_url, message } => {
430
+ handler
431
+ . handle_msg ( relay_url. to_string ( ) , Arc :: new ( message. into ( ) ) )
432
+ . await ;
433
+ }
434
+ nostr_sdk:: RelayPoolNotification :: Event {
435
+ relay_url,
436
+ subscription_id,
437
+ event,
438
+ } => {
439
+ handler
440
+ . handle (
441
+ relay_url. to_string ( ) ,
442
+ subscription_id. to_string ( ) ,
443
+ Arc :: new ( ( * event) . into ( ) ) ,
444
+ )
445
+ . await ;
454
446
}
455
- Ok ( false )
456
- } )
457
- . await
458
- } ) ? ;
459
- Ok ( ( ) )
447
+ _ => ( ) ,
448
+ }
449
+ Ok ( false )
450
+ } )
451
+ . await ? )
460
452
}
461
453
}
0 commit comments