Skip to content

Commit 173b534

Browse files
committed
Add NostrGossip
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
1 parent 4a0d09c commit 173b534

File tree

6 files changed

+98
-33
lines changed

6 files changed

+98
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
### Changed
3434

3535
- Bump uniffi to 0.29.4 (https://github.com/rust-nostr/nostr-sdk-ffi/pull/49)
36-
- Bump nostr from 0.43.0 to b20ef99 (see the Upstream CHANGELOG for more details)
36+
- Bump nostr from 0.43.0 to 7ddc15f8 (see the Upstream CHANGELOG for more details)
3737

3838
## v0.43.0 - 2025/07/28
3939

Cargo.lock

Lines changed: 51 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ logger = ["dep:tracing", "dep:tracing-subscriber"]
5050
async-trait = "0.1"
5151
async-wsocket = "0.13"
5252
futures-util = "0.3"
53-
nostr = { git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", features = ["std"] }
54-
nostr-connect = { git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", optional = true }
55-
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", optional = true }
56-
nostr-ndb = { git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", optional = true }
57-
nostr-sdk = {git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", default-features = false }
58-
nwc = { git = "https://github.com/rust-nostr/nostr", rev = "b20ef9941cccb4163e7bddd3cb4cc4c42c6b24f4", optional = true }
53+
nostr = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", features = ["std"] }
54+
nostr-connect = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", optional = true }
55+
nostr-gossip = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004" }
56+
nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004" }
57+
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", optional = true }
58+
nostr-ndb = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", optional = true }
59+
nostr-sdk = {git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", default-features = false }
60+
nwc = { git = "https://github.com/rust-nostr/nostr", rev = "7ddc15f8df4e96625a9aa8f8af4d3e5600335004", optional = true }
5961
tokio = { version = "1", features = ["sync"] }
6062
tracing = { version = "0.1", features = ["std"], optional = true }
6163
tracing-subscriber = { version = "0.3", optional = true }

src/client/builder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use uniffi::Object;
99

1010
use super::{Client, ClientOptions};
1111
use crate::database::NostrDatabase;
12+
use crate::gossip::NostrGossip;
1213
use crate::policy::{AdmitPolicy, FFI2RustAdmitPolicy};
1314
use crate::protocol::signer::NostrSigner;
1415
use crate::transport::websocket::{CustomWebSocketTransport, FFI2RustWebSocketTransport};
@@ -44,6 +45,13 @@ impl ClientBuilder {
4445
builder
4546
}
4647

48+
/// Set a gossip store
49+
pub fn gossip(&self, gossip: &NostrGossip) -> Self {
50+
let mut builder = self.clone();
51+
builder.inner = builder.inner.gossip(gossip.deref().clone());
52+
builder
53+
}
54+
4755
/// Set a custom WebSocket transport
4856
pub fn websocket_transport(&self, transport: Arc<dyn CustomWebSocketTransport>) -> Self {
4957
let mut builder = self.clone();

src/gossip/mod.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::ops::Deref;
2+
use std::sync::Arc;
3+
4+
use nostr_gossip_memory::store::NostrGossipMemory;
5+
use uniffi::Object;
6+
7+
#[derive(Object)]
8+
pub struct NostrGossip {
9+
inner: Arc<dyn nostr_gossip::NostrGossip>,
10+
}
11+
12+
impl Deref for NostrGossip {
13+
type Target = Arc<dyn nostr_gossip::NostrGossip>;
14+
15+
fn deref(&self) -> &Self::Target {
16+
&self.inner
17+
}
18+
}
19+
20+
#[uniffi::export]
21+
impl NostrGossip {
22+
/// Construct a new in-memory gossip store
23+
#[uniffi::constructor]
24+
pub fn in_memory() -> Self {
25+
Self {
26+
inner: Arc::new(NostrGossipMemory::unbounded()),
27+
}
28+
}
29+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub mod client;
1010
pub mod connect;
1111
pub mod database;
1212
pub mod error;
13+
pub mod gossip;
1314
#[cfg(feature = "logger")]
1415
pub mod logger;
1516
pub mod negentropy;

0 commit comments

Comments
 (0)