Closed grunch closed 1 year ago
Hey, for now handle_notifications
method can't handle async/await closure function.
You can try in this way:
client.connect().await?;
let subscription = SubscriptionFilter::new()
.pubkey(my_keys.public_key())
.since(timestamp());
client.subscribe(vec![subscription]).await?;
let mut notifications = client.notifications();
while let Ok(notification) = notifications.recv().await {
println!("{:?}", notification);
let event = EventBuilder::new(Kind::Custom(11000), "test", &[])
.to_event(&my_keys)
.unwrap();
client.send_event(event).await?;
}
Ok(())
It works great! thanks
Is there a way to tell from which relay a notification or event was received?
This is relevant for cases lile
let client = Client::new(&my_keys);
client.add_relay("wss://relay.nostr.info", proxy).await?;
client.add_relay("wss://rsslay.fiatjaf.com", None).await?;
client.add_relay("wss://relay.damus.io", None).await?;
client.connect().await?;
Is there a way to tell from which relay a notification or event was received?
This is relevant for cases lile
Currently no, but can be simply added in RelayPoolNotifications
enum.
What do you mean with "cases lile"?
Sorry typo, meant "cases like".
Thanks for the pointer, I'll look into that.
Sorry typo, meant "cases like".
Thanks for the pointer, I'll look into that.
Something like this:
#[derive(Debug, Clone)]
pub enum RelayPoolNotifications {
ReceivedEvent(Url, Event),
ReceivedMessage(Url, RelayMessage),
}
Hi, I'm using nostr-sdk with a project but I'm stuck sending the event, I'm starting from the Nostr SDK example on the readme and I want to send an event after receiving a specific notification but I get and error, here is a simplified code:
And I get this error
Any ideas? thanks in advance