-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add blockchain event notifier service #2378
Conversation
533e789
to
2caba0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to find a way not to have an async mutex for the whole client connections. This will create long run issues.
One way to explore this is to use a tokio::sync::watch
so you can notify multiple services that a value has been updated and here be the latest version.
958c1f8
to
5ca7915
Compare
5ca7915
to
5c7253c
Compare
5c7253c
to
10afb4e
Compare
The overall idea is good but I'd go for a different approach to send messages to clients. Namely, having an actor that collects all events from other actors, builds WS messages right away and just broadcast these messages to client connection handlers. As an optimization you could skip serialization when there is no listeners. Such approach would allow to perform the message serialization only once per each message. Now it is done |
@eugene-babichenko I'm not sure I get your point. The difference I see between the current code and what you are describing is the
part. Which I think I get, we can move the serialization before/up in the flow, right now we are just serializing ids, so it's probably not that expensive, but makes sense. Maybe you are referring to something different, though. |
I mean the following data flow:
|
I think now the data flow is just like that, but I don't see how does it simplify any code tbh. The websocket handlers were always receiving text anyway. It still makes sense to serialize at once, probably. |
941a3f0
to
7c6c721
Compare
7c6c721
to
5c92bf8
Compare
the serialization can change, but use json for now
add also setting to configuration builder, in order to test it, and improve the panic handling of the notifier client
in order to avoid platform specific dependencies in Cargo.lock
the new connection requests are handled through a new message tip changes are handled with tokio::watch because we only care about the latest state, but block changes use a broadcast to keep old ones too
5c92bf8
to
1cc7bf3
Compare
Add a
Notifier
servicerelates to #2354
just strings manually crafted (json strings with serde. Maybe we can provide binary too depending on the clientNew Block: hash
New Tip: hash
)The max_connection setting is under the
Rest
settings, for example:Questions
NewBlock
events are always sent even whenNewTip
has the same hash. I'm not sure if we want to filter these or not.It can be manually quick-tested by opening a websocket from a browser, for example: