Use Multiaddr instead of ConnectedPoint in DialError::WrongPeerId#2793
Use Multiaddr instead of ConnectedPoint in DialError::WrongPeerId#2793dmitry-markin wants to merge 2 commits into
Multiaddr instead of ConnectedPoint in DialError::WrongPeerId#2793Conversation
| address, | ||
| role_override: _, | ||
| } => DialError::WrongPeerId { obtained, address }, | ||
| ConnectedPoint::Listener { .. } => panic!( |
There was a problem hiding this comment.
Instead of a panic at runtime I would prefer making this state impossible at compile time.
Would splitting PendingConnectionError be an option @dmitry-markin?
There was a problem hiding this comment.
Thanks, this seems reasonable, I'll try to do it.
There was a problem hiding this comment.
We can replace
rust-libp2p/swarm/src/connection/pool.rs
Lines 622 to 731 in a4110a2
PendingPoint::Dialer & PendingPoint::Listener, duplicating common code on lines 651-706 for each branch. This way there will be no ambiguity whether we are handling Dialer or Listener related errors. We'll also need to duplicate code in https://github.com/libp2p/rust-libp2p/blob/a4110a2b6939d5b460f11df6dd158308f517becf/swarm/src/connection/error.rs for PendingInboundConnectionError & PendingOutboundConnectionError, which won't have the common base after these changes.
I can't weigh the code duplication vs panicking in impossible branch in this case. Should I proceed in the way described above @mxinden?
There was a problem hiding this comment.
with two big arms for
PendingPoint::Dialer&PendingPoint::Listener, duplicating common code on lines 651-706 for each branch. This way there will be no ambiguity whether we are handlingDialerorListenerrelated errors.
I would hope that we could do without the duplication here. Though I would have to play around with it myself.
We'll also need to duplicate code in https://github.com/libp2p/rust-libp2p/blob/a4110a2b6939d5b460f11df6dd158308f517becf/swarm/src/connection/error.rs for
PendingInboundConnectionError&PendingOutboundConnectionError, which won't have the common base after these changes.
👍 Off the top of my head, that seems reasonable to me.
Note that some of this might change in the near future with #2824. One potential implementation may be #2828, though as you can see that is still work in progress.
There was a problem hiding this comment.
Should I wait for #2828 to be merged before implementing the approach proposed above?
There was a problem hiding this comment.
Yes, I think that is a good idea. 🙏
In case you are interested in contributing in the meantime, many of the help wanted issues don't conflict.
There was a problem hiding this comment.
#2824 is now resolved although with a different approach than in #2828 in case you want to revive this PR @dmitry-markin.
|
This pull request has merge conflicts. Could you please resolve them @dmitry-markin? 🙏 |
|
thanks @dmitry-markin, superseeded by #5861 |
Description
Listenervariant ofConnectedPointis meaningless inDialError::WrongPeerId, so this PR replacesConnectedPointwithMultiaddr(previously returned in theDialervariant).Links to any relevant issues
This change is proposed in #2767.
Open Questions
I'm unsure whether it makes sense to also include
role_overrideintoWrongPeerIderror. This PR just drops it.Change checklist