From 9bd923fd59565c12d0b4fc3d3c5de25b34b2c396 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Fri, 13 Oct 2023 16:52:24 +0200 Subject: [PATCH] sdk: add `with_database` constructor to `RelayPool` --- crates/nostr-sdk/src/relay/pool.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/nostr-sdk/src/relay/pool.rs b/crates/nostr-sdk/src/relay/pool.rs index 7d6c35ddf..534609818 100644 --- a/crates/nostr-sdk/src/relay/pool.rs +++ b/crates/nostr-sdk/src/relay/pool.rs @@ -281,11 +281,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,