This commit is contained in:
Ren Amamiya
2026-04-01 15:19:05 +07:00
parent b547776263
commit 1b4aa02cc0
4 changed files with 14 additions and 36 deletions

View File

@@ -10,7 +10,6 @@ common = { path = "../common" }
nostr.workspace = true
nostr-sdk.workspace = true
nostr-lmdb.workspace = true
nostr-memory.workspace = true
nostr-gossip-memory.workspace = true
nostr-connect.workspace = true
nostr-blossom.workspace = true

View File

@@ -8,7 +8,6 @@ use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, SharedString,
use nostr_connect::prelude::*;
use nostr_gossip_memory::prelude::*;
use nostr_lmdb::prelude::*;
use nostr_memory::prelude::*;
use nostr_sdk::prelude::*;
mod blossom;
@@ -114,9 +113,17 @@ impl NostrRegistry {
// Construct the nostr npubs entity
let npubs = cx.new(|_| vec![]);
// Construct the nostr client builder
let mut builder = ClientBuilder::default()
// Construct the nostr lmdb instance
let lmdb = cx.foreground_executor().block_on(async move {
NostrLmdb::open(config_dir().join("nostr"))
.await
.expect("Failed to initialize database")
});
// Construct the nostr client
let client = ClientBuilder::default()
.signer(signer.clone())
.database(lmdb)
.gossip(NostrGossipMemory::unbounded())
.gossip_config(
GossipConfig::default()
@@ -125,27 +132,12 @@ impl NostrRegistry {
.sync_initial_timeout(Duration::from_millis(600)),
)
.automatic_authentication(false)
.verify_subscriptions(false)
.verify_subscriptions(true)
.connect_timeout(Duration::from_secs(10))
.sleep_when_idle(SleepWhenIdle::Enabled {
timeout: Duration::from_secs(600),
});
// Add database if not in debug mode
if !cfg!(debug_assertions) {
// Construct the nostr lmdb instance
let lmdb = cx.foreground_executor().block_on(async move {
NostrLmdb::open(config_dir().join("nostr"))
.await
.expect("Failed to initialize database")
});
builder = builder.database(lmdb);
} else {
builder = builder.database(MemoryDatabase::unbounded())
}
// Build the nostr client
let client = builder.build();
})
.build();
// Run at the end of current cycle
cx.defer_in(window, |this, _window, cx| {
@@ -911,7 +903,7 @@ fn default_messaging_relays() -> Vec<RelayUrl> {
vec![
RelayUrl::parse("wss://nos.lol").unwrap(),
RelayUrl::parse("wss://nip17.com").unwrap(),
RelayUrl::parse("wss://relay.0xchat.com").unwrap(),
RelayUrl::parse("wss://auth.nostr1.com").unwrap(),
]
}