-
Notifications
You must be signed in to change notification settings - Fork 985
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
relay: refactor stream handling away from {In,Out}boundUpgrade
#4075
Comments
@thomaseizinger |
Thank you! Feel free to ping me with any questions and/or open a draft PR at any time. |
https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md#stop-protocol
Is this a typo? |
I think terminate in this context means the same as "terminal" i.e. the end-station of something. First we have a reservation from A to R which can be considered an "open" circuit. Once R opens a stream to B, the circuit is closed (A and B can talk to each other) and thus, the end is reached aka terminated. |
Ok, I got it. Thanks! |
Threw me of in the past as well @dgarus. In case you can think of a better wording, please propose a pull request against |
@thomaseizinger
|
What you do is remember the state locally in a |
The reason this works is because streams are "interchangable", i.e. there is no identity tied to a requested stream and there also are no guarantees as to how data arrives at the remote when it is sent over multiple streams. |
@thomaseizinger |
No pressure at all! Your dedication is much appreciated :) I'll be on vacation too in the following week. Cheers 🍷 |
@dgarus I hope you had a nice vacation! I am curious whether you've already got some work locally that you can put up as a draft PR? |
@thomaseizinger |
The
libp2p-relay
protocol currently makes heavy use of theInboundUpgrade
andOutboundUpgrade
traits. This creates a lot of complexity because we actually cannot "complete" those requests within the upgrade. Instead, we have to read a message and pass the message alongside with the stream an as an event to theConnectionHandler
.Long-term, we want completely remove these upgrade traits for
ConnectionHandler
s, see #2863.Before we can do this, we need to migrate all of our own protocols away from using these traits. This issue tracks doing that for the relay protocol.
The actual steps are:
InboundUpgrade
andOutboundUpgrade
on our own types, we useReadyUpgrade
.ReadyUpgrade
directly hands the stream to theConnectionHandler
ConnectionHandler
, we can now either define a state machine ourselves or box up anasync fn
and store it inside aFuturesUnordered
that gets polled as part ofConnectionHandler::poll
InboundUpgrade::inbound_upgrade
would now happen in theasync fn
that gets stored inside aFuturesUnordered
One thing that we need to take into account is that the futures must be accompanied with a timeout, i.e. we cannot just read from the stream forever.
The text was updated successfully, but these errors were encountered: