add bootstrap flow

This commit is contained in:
2026-08-04 18:53:18 +07:00
parent ebdb07f652
commit 7300c5d1fd
5 changed files with 321 additions and 15 deletions
+13 -2
View File
@@ -2,12 +2,11 @@ use std::time::Duration;
use anyhow::{Context, Result, anyhow};
use nostr_gossip_memory::prelude::*;
use nostr_sdk::prelude::*;
#[cfg(not(target_arch = "wasm32"))]
use nostr_lmdb::prelude::*;
#[cfg(target_arch = "wasm32")]
use nostr_memory::prelude::*;
use nostr_sdk::prelude::*;
use crate::signer::UniversalSigner;
@@ -51,6 +50,8 @@ impl NostrBackend {
.gossip(NostrGossipMemory::unbounded())
.gossip_config(GossipConfig::default().no_background_refresh())
.connect_timeout(Duration::from_secs(10))
.verify_subscriptions(true)
.ban_relay_on_mismatch(true)
.sleep_when_idle(SleepWhenIdle::Enabled {
timeout: Duration::from_secs(600),
})
@@ -72,6 +73,16 @@ impl NostrBackend {
Ok(())
}
/// Add a relay used only for discovery (e.g. NIP-65 indexer relays).
/// No subscriptions or writes are routed through it.
pub async fn add_discovery_relay(&self, url: &str) -> Result<()> {
self.client
.add_relay(url)
.capabilities(RelayCapabilities::DISCOVERY)
.await?;
Ok(())
}
pub async fn connect(&self) {
self.client.connect().await;
}