diff --git a/crates/nostr-sdk-db/src/memory.rs b/crates/nostr-sdk-db/src/memory.rs index bd2c4ceed..f15c4f84d 100644 --- a/crates/nostr-sdk-db/src/memory.rs +++ b/crates/nostr-sdk-db/src/memory.rs @@ -27,6 +27,7 @@ impl From for DatabaseError { #[derive(Debug, Default)] pub struct MemoryDatabase { seen_event_ids: Arc>>>, + // TODO: add messages queue? (messages not sent) } impl MemoryDatabase { diff --git a/crates/nostr-sdk/src/relay/mod.rs b/crates/nostr-sdk/src/relay/mod.rs index 694a3664b..1885fe1a7 100644 --- a/crates/nostr-sdk/src/relay/mod.rs +++ b/crates/nostr-sdk/src/relay/mod.rs @@ -433,16 +433,6 @@ impl Relay { self.relay_sender.max_capacity() - self.relay_sender.capacity() } - /* fn is_auto_connect_loop_running(&self) -> bool { - self.auto_connect_loop_running.load(Ordering::SeqCst) - } - - fn set_auto_connect_loop_running(&self, value: bool) { - let _ = - self.auto_connect_loop_running - .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| Some(value)); - } */ - fn is_scheduled_for_stop(&self) -> bool { self.scheduled_for_stop.load(Ordering::SeqCst) } @@ -787,7 +777,11 @@ impl Relay { if size <= max_size { match RawRelayMessage::from_json(&data) { Ok(msg) => { - tracing::trace!("Received message to {}: {:?}", relay.url, msg); + tracing::trace!( + "Received message from {}: {:?}", + relay.url, + msg + ); if let Err(err) = relay .pool_sender .send(RelayPoolMessage::ReceivedMsg { diff --git a/crates/nostr-sdk/src/relay/pool.rs b/crates/nostr-sdk/src/relay/pool.rs index c384eb926..4b2e73d18 100644 --- a/crates/nostr-sdk/src/relay/pool.rs +++ b/crates/nostr-sdk/src/relay/pool.rs @@ -175,9 +175,18 @@ impl RelayPoolTask { { Ok(seen) => { if !seen { + if let Err(e) = + this.database.save_event(&event).await + { + tracing::error!( + "Impossible to save event {}: {e}", + event.id + ); + } + let notification = RelayPoolNotification::Event( relay_url.clone(), - event.as_ref().clone(), + *event.clone(), ); let _ = this.notification_sender.send(notification);