Skip to content

Commit fe4b809

Browse files
committed
sdk: add negentropy example
1 parent 4c5a376 commit fe4b809

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

crates/nostr-sdk/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,8 @@ name = "shutdown-on-drop"
7676
name = "subscriptions"
7777
required-features = ["all-nips"]
7878

79+
[[example]]
80+
name = "negentropy"
81+
7982
[[example]]
8083
name = "nip65"

crates/nostr-sdk/examples/reconcilie.rs renamed to crates/nostr-sdk/examples/negentropy.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ async fn main() -> Result<()> {
1717

1818
client.connect().await;
1919

20+
let my_items = Vec::new();
2021
let filter = Filter::new()
2122
.author(my_keys.public_key().to_string())
2223
.limit(10);
2324
let relay = client.relay("wss://atl.purplerelay.com").await?;
24-
relay.reconcilie(filter, Vec::new()).await?;
25+
relay.reconcilie(filter, my_items).await?;
26+
27+
client
28+
.handle_notifications(|notification| async {
29+
if let RelayPoolNotification::Event(_url, event) = notification {
30+
println!("{:?}", event);
31+
}
32+
Ok(false) // Set to true to exit from the loop
33+
})
34+
.await?;
2535

2636
Ok(())
2737
}

0 commit comments

Comments
 (0)