-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Currently, the stream is opened randomly on connections.
It would be great to allow callers to open a stream on an explicit connection ID.
Motivation
For instance, when opening a stream, you can choose to prefer direct connections or relay connections.
Requirements
Add a method like
pub async fn open_stream_on_connection(
&mut self,
peer: PeerId,
connection: ConnectionId,
protocol: StreamProtocol,
) -> Result<Stream, OpenStreamError>
ConnectionId is enough because the caller can maintain a ConnectionId <-> Connection state map of its own.
Open questions
Actually, I’ve implemented one for my project (with AI):
It works fine on my project fungi.
I'm not sure it is a necessary feature for rust-libp2p.
If it’s done correctly, I’d love to open a PR.
If not, and there’s a better way to achieve the same result, please let me know.
Furthermore, it would be great if the listener side could add a method like accept_with_id that also provides the connection ID for new streams.
Are you planning to do it yourself in a pull request?
Yes