From 6fd954954a2862fac6638f3ae59f9fcfe9d24732 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Mon, 13 Nov 2023 11:13:56 +0100 Subject: [PATCH] sdk: update `Realy::get_events_of` method --- crates/nostr-sdk/src/relay/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/nostr-sdk/src/relay/mod.rs b/crates/nostr-sdk/src/relay/mod.rs index 0ceec7a49..b6e53f515 100644 --- a/crates/nostr-sdk/src/relay/mod.rs +++ b/crates/nostr-sdk/src/relay/mod.rs @@ -1349,7 +1349,7 @@ impl Relay { } /// Get events of filters with custom callback - pub async fn get_events_of_with_callback( + async fn get_events_of_with_callback( &self, filters: Vec, timeout: Duration, @@ -1378,13 +1378,20 @@ impl Relay { } /// Get events of filters + /// + /// Get events from local database and relay pub async fn get_events_of( &self, filters: Vec, timeout: Duration, opts: FilterOptions, ) -> Result, Error> { - let events: Mutex> = Mutex::new(Vec::new()); + let stored_events: Vec = self + .database + .query(filters.clone()) + .await + .unwrap_or_default(); + let events: Mutex> = Mutex::new(stored_events); self.get_events_of_with_callback(filters, timeout, opts, |event| async { let mut events = events.lock().await; events.push(event);