-
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
draft: progressing on removing {In,Out}boundUpgrade
#4828
base: master
Are you sure you want to change the base?
Conversation
This would need to be deprecated first.
To make sure we are on the same page, the end-goal is to even get rid of pub trait ConnectionHandler: Send + 'static {
/// A type representing the message(s) a [`NetworkBehaviour`](crate::behaviour::NetworkBehaviour) can send to a [`ConnectionHandler`] via [`ToSwarm::NotifyHandler`](crate::behaviour::ToSwarm::NotifyHandler)
type FromBehaviour: fmt::Debug + Send + 'static;
/// A type representing message(s) a [`ConnectionHandler`] can send to a [`NetworkBehaviour`](crate::behaviour::NetworkBehaviour) via [`ConnectionHandlerEvent::NotifyBehaviour`].
type ToBehaviour: fmt::Debug + Send + 'static;
fn listen_protocol(&self) -> &[StreamProtocol]; Note the removal of I don't feel strongly about how we get here. Though I wonder whether a single step process (i.e. the removal of the associated traits right away) is simpler for a user. |
That would be great! That design unfortunately creates several error cases when we try to dispatch the stream back to the |
Description
Attempting to make progress on simplifying the
ConnectionHandler
interface (#2863), specifically, how we should deal with{In,Out}boundUpgrade
.The idea of this work is to eventually replace
{In,Out}boundUpgrade
with a trait no longer does any (async) upgrading. Instead, we only want it to express, which protocols are available, i.e.UpgradeInfo
.To get there, I think the easiest migration for users will be if we move them away from using
{In,Out}BoundUpgrade
altogether.libp2p-swarm
that implement the old traits but hard hardcode to enforceStreamProtocol
andStream
. We can then deprecate the existing types withinlibp2p-core
and remove them eventually.ConnectionHandler::{In,Out}boundProtocol
without actually breaking users.One thing that this will allow us to do is require a new trait bound for the
Info
of an upgrade that exposes the underlyingStreamProtocol
. By adding this bound, we can remove a lot of allocations from thelibp2p_swarm::Connection::poll
function. At the moment, the contract here isAsRef<str>
meaning, we are re-allocating all protocols strings here very, very often.Notes & open questions
Change checklist