Skip to content
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

consistently use protocol.ID instead of strings #2004

Merged

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Jan 20, 2023

This reduces the string to protocol.ID translations happening at various places in the code

Fixes #1886

@sukunrt sukunrt marked this pull request as ready for review January 20, 2023 09:02
Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pull in multiformats/go-multistream#95, so we can see how this will look like in the end?

p2p/protocol/identify/id.go Outdated Show resolved Hide resolved
p2p/host/basic/basic_host.go Outdated Show resolved Hide resolved
@sukunrt
Copy link
Member Author

sukunrt commented Jan 20, 2023

Should I change network.ConnectionState?

@sukunrt
Copy link
Member Author

sukunrt commented Jan 20, 2023

Can you pull in multiformats/go-multistream#95, so we can see how this will look like in the end?

Do you mean to point the multistream module to the new changes and check? If so, sukunrt/fix-pid-string-conv-ms-merged (https://github.com/sukunrt/go-libp2p/tree/sukunrt/fix-pid-string-conv-ms-merged)
This is the branch with the merged changes.

@marten-seemann
Copy link
Contributor

Can you pull in multiformats/go-multistream#95, so we can see how this will look like in the end?

Do you mean to point the multistream module to the new changes and check? If so, sukunrt/fix-pid-string-conv-ms-merged (https://github.com/sukunrt/go-libp2p/tree/sukunrt/fix-pid-string-conv-ms-merged) This is the branch with the merged changes.

Nice!!!

Should I change network.ConnectionState?

I think it would make sense. What do you think? Does it make the code easier?

@sukunrt
Copy link
Member Author

sukunrt commented Jan 21, 2023

I think changing network.ConnectionState is correct. That way internally it is always protocol.ID and we only convert to string when dealing with external lib like tls or translating to protobufs.

Updated sukunrt/fix-pid-string-conv-ms-merged with changed network.ConnectionState

@marten-seemann
Copy link
Contributor

@sukunrt I just cut a new release of go-multistream with all your changes: https://github.com/multiformats/go-multistream/tree/v0.4.0.

Can you update this PR to use the release?

@sukunrt sukunrt force-pushed the sukunrt/fix-pid-string-conversion branch from 570f5b9 to d1bceb2 Compare January 27, 2023 06:39
@sukunrt sukunrt force-pushed the sukunrt/fix-pid-string-conversion branch from 9e35ce9 to 4ab7c5c Compare January 27, 2023 06:54
@sukunrt
Copy link
Member Author

sukunrt commented Jan 27, 2023

Updated the branch with all changes merged.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a full review, and this looks really good to me. One minor thing, then this should be good to merge. 🎉

core/network/conn.go Outdated Show resolved Hide resolved
core/protocol/switch.go Show resolved Hide resolved
@marten-seemann marten-seemann changed the title Change PeerStore interface to use protocol.ID consistently use protocol.ID instead of strings Jan 27, 2023
@marten-seemann marten-seemann merged commit 6b9c116 into libp2p:master Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clean up usage of string vs. protocol.ID
2 participants