From ef18aa148b7c8ba2d385a83d74cf174af6498de5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 29 Aug 2018 16:08:25 -0700 Subject: [PATCH] directly parse peer IDs as peer IDs No need to parse it as a hash first. License: MIT Signed-off-by: Steven Allen --- namesys/routing.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/namesys/routing.go b/namesys/routing.go index c533daada..65da47a2f 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -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