Description
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
and ConnectionHandler::OutboundOpenInfo
completely in favor of ConnectionHandler
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
- [ ] https://github.com/libp2p/rust-libp2p/pull/3760
- [ ] https://github.com/libp2p/rust-libp2p/pull/3762
- [ ] https://github.com/libp2p/rust-libp2p/pull/3763
- [ ] https://github.com/libp2p/rust-libp2p/issues/4075
- [ ] https://github.com/libp2p/rust-libp2p/pull/3914
- [ ] https://github.com/libp2p/rust-libp2p/issues/4510
- [ ] https://github.com/libp2p/rust-libp2p/pull/4901
- [ ] #4900
- [ ] Write tutorial on how to write your own `ConnectionHandler`, documenting use of `futures-bounded` and oneshots