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

core/peer: remove deprecated Encode function #2566

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

marten-seemann
Copy link
Contributor

No description provided.

@Icarus9913
Copy link
Contributor

Icarus9913 commented Sep 12, 2023

How about I commit PR to improve it for this two project after you release go-libp2p v0.31.z or v0.32.0?
@marten-seemann

@marten-seemann
Copy link
Contributor Author

How about I commit PR to improve it for this two project after you release go-libp2p v0.31.z or v0.32.0? @marten-seemann

You actually don't have to wait for the release, you could do this change right now if you want to. This would make updating the new go-libp2p later easier. Please tag me in those PRs, happy to review :)

@Icarus9913
Copy link
Contributor

This would make updating the new go-libp2p later easier. Please tag me in those PRs, happy to review :)

OK, I noticed kubo and lotus still use go-libp2p v0.30.0, I gonna update them to v0.31.0 and remove the deprecated method.

@marten-seemann
Copy link
Contributor Author

This would make updating the new go-libp2p later easier. Please tag me in those PRs, happy to review :)

OK, I noticed kubo and lotus still use go-libp2p v0.30.0, I gonna update them to v0.31.0 and remove the deprecated method.

Please don't mix those two changes. Kubo and Lotus do some network testing before updating to a new libp2p release, so that's a bigger change. Replacing the deprecated function is something that doesn't need to be tested on the live network, so it would make sense to create a PR with only that change.

@Icarus9913
Copy link
Contributor

Icarus9913 commented Sep 12, 2023

@marten-seemann
Oh bad, I checked go-libp2p release v0.31.0, it looks the peer.Encode is still complete. And it might deprecated in the main branch. So I can't just update go-libp2p from v0.30.0 to v0.31.0 and remove the peer.Encode ?

Please take a look.

go-libp2p/core/peer/peer.go

Lines 126 to 146 in 87a8d4e

// Decode accepts an encoded peer ID and returns the decoded ID if the input is
// valid.
//
// The encoded peer ID can either be a CID of a key or a raw multihash (identity
// or sha256-256).
func Decode(s string) (ID, error) {
if strings.HasPrefix(s, "Qm") || strings.HasPrefix(s, "1") {
// base58 encoded sha256 or identity multihash
m, err := mh.FromB58String(s)
if err != nil {
return "", fmt.Errorf("failed to parse peer ID: %s", err)
}
return ID(m), nil
}
c, err := cid.Decode(s)
if err != nil {
return "", fmt.Errorf("failed to parse peer ID: %s", err)
}
return FromCid(c)
}

@marten-seemann marten-seemann merged commit fd2a1ed into master Sep 14, 2023
11 checks passed
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.

3 participants