-
Notifications
You must be signed in to change notification settings - Fork 999
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
protocols/identify: Move I/O to ConnectionHandler #2885
Comments
The problem with today's implementation of identify is that we only know the observed address in the |
@thomaseizinger could you shed some light on how you envisioned passing the observed address from I can't really see where to do that as Thanks :) |
You need to implement |
right, thanks Thomas. What about |
I think you will need to store those in the A couple of refactorings coming in will affect this but overall, this should still work I believe! |
Discussed out-of-band with @jxs today. Passing them in Instead I suggest passing an event up from the |
Even once we have a mechanism where they change, I'd expect the behaviour to be notified. It feels more appropriate to pass it down when it changes instead of requesting it every time. Esp. because that allows the handler to answer incoming streams without interacting with the behaviour which simplifies things a lot. |
👍 like we do for new listen addresses via Given that we don't have these mechanisms yet, I suggest proceeding with the above, that is have the |
It makes the implementation of the handler more complicated because you now have to suspend the substream and can't use async-await to implement the protocol (unless you use a channel). At the moment, we know that the protocols don't change so we just only send the update once. Later, once they can change, we can send the update every time it is modified. Unless we disagree on the bigger idea that we don't want to push state into the handler, this should be preferred where possible because it is IMO a simpler design. |
Closing here with #3208 merged. |
Description
I/O should not happen in the
NetworkBehaviour
implementation. It should happen in theConnectionHandler
implementation.Motivation
All
NetworkBehaviour
implementations are driven by a single future task. Opposite to that we spawn a new future task for every connection. Doing as much as possible, especially I/O, on the connection tasks and not on the main task allows logic to potentially run in parallel.Current Implementation
Today
libp2p-identify
drives the future returning a response to a remote in theNetworkBehaviour::poll
implementation.rust-libp2p/protocols/identify/src/identify.rs
Lines 53 to 54 in 66c2755
Are you planning to do it yourself in a pull request?
No
The text was updated successfully, but these errors were encountered: