-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
directly parse peer IDs as peer IDs #5409
Conversation
No need to parse it as a hash first. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
@kevina this is one of the few to only changes we'll need to make to go-ipfs to use non-byte-array CIDs. |
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
@@ -55,19 +55,13 @@ func (r *IpnsResolver) resolveOnce(ctx context.Context, name string, options *op | |||
} | |||
|
|||
name = strings.TrimPrefix(name, "/ipns/") | |||
hash, err := mh.FromB58String(name) | |||
pid, err := peer.IDB58Decode(name) |
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.
Unless I am missing something, this is not performing the same set of checks. In particular peer.IDB58Decode does not check it is a valid Multihash: https://github.com/libp2p/go-libp2p-peer/blob/master/peer.go#L121:L127
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.
It calls mh.FromB58String
internally.
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.
Oops sorry.
@kevina could I get a ✔️? |
namesys/routing.go
Outdated
@@ -55,19 +55,13 @@ func (r *IpnsResolver) resolveOnce(ctx context.Context, name string, options *op | |||
} | |||
|
|||
name = strings.TrimPrefix(name, "/ipns/") | |||
hash, err := mh.FromB58String(name) | |||
pid, err := peer.IDB58Decode(name) | |||
if err != nil { | |||
// name should be a multihash. if it isn't, error out here. | |||
log.Debugf("RoutingResolver: bad input hash: [%s]\n", name) |
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.
This error message should likely change to
log.Debugf("RoutingResolver: could not convert public key hash %s to peer ID: %s\n", name, err)
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.
Fixed (although I chose a different error message as that one isn't quite right either).
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
No need to parse it as a hash first.