-
Notifications
You must be signed in to change notification settings - Fork 949
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
swarm: Deprecate ConnectionHandler::{In,Out}boundOpenInfo
#3268
Comments
Linking the original discussion here: #1709 The motivation for adding this was to properly deal with upgrade errors. Hence, I'd suggest that we proceed here once #2863 is implemented. Depending on the outcome of the discussion in #3353 (comment), this requirement will go away completely and we should be able to remove these associated types without harming existing usecases. #1710 also mentions that there is no guarantee that a call to Long-term, I'd like us to only expose a list of protocols from a I wonder what a good migration plan is from one to the other interface. It is quite a big change so I'd want to offer a smooth migration path to our users. |
One thing that just came to my mind that is easier with the current design: Being able to pass state to as part of creating a new stream allows With the current design, you just drain a list of commands and open a new stream per command, passing along the data they need. |
Long term |
#3763 is a pretty classic refactoring that users will have to do. The new version is more verbose but I think that for new-comers, it is easier to understand because there is a smaller API surface to learn. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This patch refactors `libp2p-request-response` to not use the "upgrade infrastructure" provided by `libp2p-swarm`. Instead, we directly convert the negotiated streams into futures that read and write the messages. Related: #3268. Related: #2863. Pull-Request: #3914. Co-authored-by: Yiannis Marangos <[email protected]>
This refactoring addresses several aspects of the current handler implementation: - Remove the manual state machine for outbound streams in favor of using `async-await`. - Use `oneshot`s to track the number of requested outbound streams - Use `futures_bounded::FuturesMap` to track the execution of a stream, thus applying a timeout to the entire request. Resolves: #3130. Related: #3268. Related: #4510. Pull-Request: #4901.
This patch refactors `libp2p-request-response` to not use the "upgrade infrastructure" provided by `libp2p-swarm`. Instead, we directly convert the negotiated streams into futures that read and write the messages. Related: libp2p#3268. Related: libp2p#2863. Pull-Request: libp2p#3914. Co-authored-by: Yiannis Marangos <[email protected]>
A brief search around the codebase showed that there is no use case for the open info. Should this be added to |
Yes we could. We would have to issue a deprecation first to make upstream users aware that these associated types are going away. |
Currently, a user can specify an arbitrary payload type that can be passed a long with the opening of an inbound or an outbound stream. In general, being able to pass along user data with an asynchronous operation can be helpful because one doesn't need to track this information locally. Furthermore, for some asynchronous operations (like connection dialing in the case of relay's and the dcutr protocol) it is very important that one can 1-to-1 associate the initiated action with the result of the asynchronous operation.
Streams however are completely interchangeable in libp2p once the protocol to be spoken on top of it has been negotiated. Thus, we should be able to remove
ConnectionHandler::InboundOpenInfo
andConnectionHandler::OutboundOpenInfo
completely in favor ofConnectionHandler
s tracking the user data in a FIFO queue.In fact, that is what we are doing within
swarm::Connection
anyway. Upon opening a new stream, we just associate it with the next upgrade from the list:rust-libp2p/swarm/src/connection.rs
Lines 289 to 303 in ee77513
Tasks
OutboundOpenInfo
#3760OutboundOpenInfo
#3762OutboundOpenInfo
#3763{In,Out}boundUpgrade
#4075oneshot
s andasync-await
for outbound streams #4901The text was updated successfully, but these errors were encountered: