From a1d67c50c8ebc5395b069e30b60d66e0c7de5a5a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 14 Feb 2024 13:47:11 +0000 Subject: feat: send to default relays, blast repo event improve the distribution of events by sending to default relays in addition to user and repo relays. for better discoverability of repo events, this is also blasted. a temporary fix to blast everything was removed. the less reliable purplepages.es relay is moved to more_fallback_relays that currently isn't used --- src/client.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index 97cb856..9bc171a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -26,6 +26,7 @@ pub struct Client { client: nostr_sdk::Client, fallback_relays: Vec, more_fallback_relays: Vec, + blaster_relays: Vec, } #[cfg_attr(test, automock)] @@ -37,6 +38,7 @@ pub trait Connect { async fn disconnect(&self) -> Result<()>; fn get_fallback_relays(&self) -> &Vec; fn get_more_fallback_relays(&self) -> &Vec; + fn get_blaster_relays(&self) -> &Vec; async fn send_event_to(&self, url: &str, event: nostr::event::Event) -> Result; async fn get_events( &self, @@ -55,7 +57,6 @@ impl Connect for Client { ] } else { vec![ - "wss://purplepages.es".to_string(), "wss://relay.damus.io".to_string(), "wss://nostr-pub.wellorder.net".to_string(), "wss://nos.lol".to_string(), @@ -70,6 +71,7 @@ impl Connect for Client { ] } else { vec![ + "wss://purplepages.es".to_string(), "wss://nostr.wine/".to_string(), "wss://eden.nostr.land/".to_string(), "wss://relay.nostr.band/".to_string(), @@ -77,10 +79,16 @@ impl Connect for Client { ] }; + let blaster_relays: Vec = if std::env::var("NGITTEST").is_ok() { + vec!["ws://localhost:8057".to_string()] + } else { + vec!["wss://nostr.mutinywallet.com".to_string()] + }; Client { client: nostr_sdk::Client::new(&nostr::Keys::generate()), fallback_relays, more_fallback_relays, + blaster_relays, } } fn new(opts: Params) -> Self { @@ -88,6 +96,7 @@ impl Connect for Client { client: nostr_sdk::Client::new(&opts.keys.unwrap_or(nostr::Keys::generate())), fallback_relays: opts.fallback_relays, more_fallback_relays: opts.more_fallback_relays, + blaster_relays: opts.blaster_relays, } } @@ -110,6 +119,10 @@ impl Connect for Client { &self.more_fallback_relays } + fn get_blaster_relays(&self) -> &Vec { + &self.blaster_relays + } + async fn send_event_to(&self, url: &str, event: Event) -> Result { self.client.add_relay(url).await?; self.client.connect_relay(url).await?; @@ -243,6 +256,7 @@ pub struct Params { pub keys: Option, pub fallback_relays: Vec, pub more_fallback_relays: Vec, + pub blaster_relays: Vec, } fn get_dedup_events(relay_results: Vec>>) -> Vec { -- cgit v1.2.3