chore: simplify codebase and prepare for multi-platforms #28
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -4444,17 +4444,6 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nostr-memory"
|
|
||||||
version = "0.44.0"
|
|
||||||
source = "git+https://github.com/rust-nostr/nostr#6503a7a86e904800de54c8592a6811f5f17cd805"
|
|
||||||
dependencies = [
|
|
||||||
"btreecap",
|
|
||||||
"nostr",
|
|
||||||
"nostr-database",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-sdk"
|
name = "nostr-sdk"
|
||||||
version = "0.44.1"
|
version = "0.44.1"
|
||||||
@@ -6613,7 +6602,6 @@ dependencies = [
|
|||||||
"nostr-connect",
|
"nostr-connect",
|
||||||
"nostr-gossip-memory",
|
"nostr-gossip-memory",
|
||||||
"nostr-lmdb",
|
"nostr-lmdb",
|
||||||
"nostr-memory",
|
|
||||||
"nostr-sdk",
|
"nostr-sdk",
|
||||||
"petname",
|
"petname",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ reqwest_client = { git = "https://github.com/zed-industries/zed" }
|
|||||||
|
|
||||||
# Nostr
|
# Nostr
|
||||||
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" }
|
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" }
|
||||||
nostr-memory = { git = "https://github.com/rust-nostr/nostr" }
|
|
||||||
nostr-connect = { git = "https://github.com/rust-nostr/nostr" }
|
nostr-connect = { git = "https://github.com/rust-nostr/nostr" }
|
||||||
nostr-blossom = { git = "https://github.com/rust-nostr/nostr" }
|
nostr-blossom = { git = "https://github.com/rust-nostr/nostr" }
|
||||||
nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr" }
|
nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr" }
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ common = { path = "../common" }
|
|||||||
nostr.workspace = true
|
nostr.workspace = true
|
||||||
nostr-sdk.workspace = true
|
nostr-sdk.workspace = true
|
||||||
nostr-lmdb.workspace = true
|
nostr-lmdb.workspace = true
|
||||||
nostr-memory.workspace = true
|
|
||||||
nostr-gossip-memory.workspace = true
|
nostr-gossip-memory.workspace = true
|
||||||
nostr-connect.workspace = true
|
nostr-connect.workspace = true
|
||||||
nostr-blossom.workspace = true
|
nostr-blossom.workspace = true
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, SharedString,
|
|||||||
use nostr_connect::prelude::*;
|
use nostr_connect::prelude::*;
|
||||||
use nostr_gossip_memory::prelude::*;
|
use nostr_gossip_memory::prelude::*;
|
||||||
use nostr_lmdb::prelude::*;
|
use nostr_lmdb::prelude::*;
|
||||||
use nostr_memory::prelude::*;
|
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
|
|
||||||
mod blossom;
|
mod blossom;
|
||||||
@@ -114,9 +113,17 @@ impl NostrRegistry {
|
|||||||
// Construct the nostr npubs entity
|
// Construct the nostr npubs entity
|
||||||
let npubs = cx.new(|_| vec![]);
|
let npubs = cx.new(|_| vec![]);
|
||||||
|
|
||||||
// Construct the nostr client builder
|
// Construct the nostr lmdb instance
|
||||||
let mut builder = ClientBuilder::default()
|
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())
|
.signer(signer.clone())
|
||||||
|
.database(lmdb)
|
||||||
.gossip(NostrGossipMemory::unbounded())
|
.gossip(NostrGossipMemory::unbounded())
|
||||||
.gossip_config(
|
.gossip_config(
|
||||||
GossipConfig::default()
|
GossipConfig::default()
|
||||||
@@ -125,27 +132,12 @@ impl NostrRegistry {
|
|||||||
.sync_initial_timeout(Duration::from_millis(600)),
|
.sync_initial_timeout(Duration::from_millis(600)),
|
||||||
)
|
)
|
||||||
.automatic_authentication(false)
|
.automatic_authentication(false)
|
||||||
.verify_subscriptions(false)
|
.verify_subscriptions(true)
|
||||||
.connect_timeout(Duration::from_secs(10))
|
.connect_timeout(Duration::from_secs(10))
|
||||||
.sleep_when_idle(SleepWhenIdle::Enabled {
|
.sleep_when_idle(SleepWhenIdle::Enabled {
|
||||||
timeout: Duration::from_secs(600),
|
timeout: Duration::from_secs(600),
|
||||||
});
|
})
|
||||||
|
.build();
|
||||||
// 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();
|
|
||||||
|
|
||||||
// Run at the end of current cycle
|
// Run at the end of current cycle
|
||||||
cx.defer_in(window, |this, _window, cx| {
|
cx.defer_in(window, |this, _window, cx| {
|
||||||
@@ -911,7 +903,7 @@ fn default_messaging_relays() -> Vec<RelayUrl> {
|
|||||||
vec![
|
vec![
|
||||||
RelayUrl::parse("wss://nos.lol").unwrap(),
|
RelayUrl::parse("wss://nos.lol").unwrap(),
|
||||||
RelayUrl::parse("wss://nip17.com").unwrap(),
|
RelayUrl::parse("wss://nip17.com").unwrap(),
|
||||||
RelayUrl::parse("wss://relay.0xchat.com").unwrap(),
|
RelayUrl::parse("wss://auth.nostr1.com").unwrap(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user