diff --git a/crates/nostr-sdk/src/relay/mod.rs b/crates/nostr-sdk/src/relay/mod.rs index 1885fe1a7..1c13cc62b 100644 --- a/crates/nostr-sdk/src/relay/mod.rs +++ b/crates/nostr-sdk/src/relay/mod.rs @@ -257,6 +257,7 @@ pub struct Relay { document: Arc>, opts: RelayOptions, stats: RelayConnectionStats, + #[allow(dead_code)] database: Arc, scheduled_for_stop: Arc, scheduled_for_termination: Arc, diff --git a/crates/nostr-sdk/src/relay/pool.rs b/crates/nostr-sdk/src/relay/pool.rs index 4b2e73d18..c073b6aad 100644 --- a/crates/nostr-sdk/src/relay/pool.rs +++ b/crates/nostr-sdk/src/relay/pool.rs @@ -199,8 +199,10 @@ impl RelayPoolTask { } // Set event as seen by relay - if let Err(e) = - this.database.event_id_seen(event.id, Some(relay_url)).await + if let Err(e) = this + .database + .event_id_seen(event.id, Some(relay_url)) + .await { tracing::error!( "Impossible to set event {} as seen by relay: {e}", @@ -329,11 +331,14 @@ impl Drop for RelayPool { impl RelayPool { /// Create new `RelayPool` pub fn new(opts: RelayPoolOptions) -> Self { + Self::with_database(opts, Arc::new(MemoryDatabase::new())) + } + + /// New with database + pub fn with_database(opts: RelayPoolOptions, database: Arc) -> Self { let (notification_sender, _) = broadcast::channel(opts.notification_channel_size); let (pool_task_sender, pool_task_receiver) = mpsc::channel(opts.task_channel_size); - let database = Arc::new(MemoryDatabase::new()); - let relay_pool_task = RelayPoolTask::new( database.clone(), pool_task_receiver,