mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 23:21:54 +08:00
directly parse peer IDs as peer IDs
No need to parse it as a hash first. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -55,19 +55,13 @@ func (r *IpnsResolver) resolveOnce(ctx context.Context, name string, options *op
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = strings.TrimPrefix(name, "/ipns/")
|
name = strings.TrimPrefix(name, "/ipns/")
|
||||||
hash, err := mh.FromB58String(name)
|
pid, err := peer.IDB58Decode(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// name should be a multihash. if it isn't, error out here.
|
// name should be a multihash. if it isn't, error out here.
|
||||||
log.Debugf("RoutingResolver: bad input hash: [%s]\n", name)
|
log.Debugf("RoutingResolver: bad input hash: [%s]\n", name)
|
||||||
return "", 0, err
|
return "", 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pid, err := peer.IDFromBytes(hash)
|
|
||||||
if err != nil {
|
|
||||||
log.Debugf("RoutingResolver: could not convert public key hash %s to peer ID: %s\n", name, err)
|
|
||||||
return "", 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name should be the hash of a public key retrievable from ipfs.
|
// Name should be the hash of a public key retrievable from ipfs.
|
||||||
// We retrieve the public key here to make certain that it's in the peer
|
// We retrieve the public key here to make certain that it's in the peer
|
||||||
// store before calling GetValue() on the DHT - the DHT will call the
|
// store before calling GetValue() on the DHT - the DHT will call the
|
||||||
|
Reference in New Issue
Block a user