1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-25 06:58:18 +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:
Steven Allen
2018-08-29 16:08:25 -07:00
parent 2362c6d3d8
commit ef18aa148b

View File

@ -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)
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.
// 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