-
Notifications
You must be signed in to change notification settings - Fork 1.2k
net: Strip previous p2p prefix before concatenating addresses #11078
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
Changes from 2 commits
e85be1c
d4ed260
284f333
f64d79c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,8 +170,11 @@ pub struct MultiaddrWithPeerId { | |
| impl MultiaddrWithPeerId { | ||
| /// Concatenates the multiaddress and peer ID into one multiaddress containing both. | ||
| pub fn concat(&self) -> Multiaddr { | ||
| let proto = multiaddr::Protocol::P2p(From::from(self.peer_id)); | ||
| self.multiaddr.clone().with(proto) | ||
| let mut addr = self.multiaddr.clone(); | ||
| if matches!(addr.iter().last(), Some(multiaddr::Protocol::P2p(_))) { | ||
lexnv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| addr.pop(); | ||
| } | ||
|
Comment on lines
+175
to
+177
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be difficult to ensure that We should investigate how peer IDs end up in the address that is supposed to be without a peer ID.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Litep2p appends the I don't believe this will cause issues since we are dialing from the transport manager either way:
I would still keep this one as a tiny defensive check for future proofing |
||
| addr.with(multiaddr::Protocol::P2p(From::from(self.peer_id))) | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth adding a comment why we do it