-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target a subset of pool relays for subscriptions and report on which relays have events #168
Comments
Hi, currently it's possible to subscribe only to specific relays: let relay = client.relay("wss://relay.example.com").await?;
relay.subscribe(filters, wait).await?; // This use the default internal ID (the pool use a different internal ID)
// OR
relay.subscribe_with_internal_id(InternalSubscriptionId::Custom("my_custom_id".to_string()), filters, wait).await?; But yes, I can try to add a method to do this automatically, specifying a list of relays.
Regarding this, I suppose that it's needed a DB. I tried to implement it times ago but it's difficult to generalize it. I'm thinking a way to implement again a DB to store all the received events and allow the user to query from it without messing up the code. Probably using client
.handle_notifications(|notification| async {
if let RelayPoolNotification::Message(url, message) = notification {
// handle message
}
Ok(false) // Set to true to exit from the loop
})
.await?; |
Thanks! That sounds ideal.
Perhaps my use of the word query is misleading. I can see a need for a full event cache stored in a database but this requirement is way more simplistic. What about adding a |
Ah, yeah, I already store in RAM the seen event ids in the What do you think? |
Yes that sounds good, or potentially for cleaner lifetime management use a reference to a Url. |
Hey, it's not possible to send, get or request events (or messages) to/from specific relays. Get events from specific relays: client.get_events_from(["wss://relay1.com", "wss://other.relay"], ...).await?; Send event to specific relays: client.send_event_to(["wss://relay1.com", "wss://other.relay"], ...).await?; To know where an event was seen: let database = client.database();
let urls = database.event_seen_on_relays(event_id).await?; |
The |
Describe the enhancement
Use case
Additional context
I'm very much interested in your thoughts on this generally and how you would approach it. I'm also happy to contribute towards a PR.
The text was updated successfully, but these errors were encountered: