Skip to content

Commit

Permalink
feat: resolve peer IDs as CIDs
Browse files Browse the repository at this point in the history
This adds support for resolving /ipns/<cidv1-libp2p-key>

cc #5287

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Feb 11, 2020
1 parent 49f768d commit ef00a67
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions namesys/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"time"

lru "github.com/hashicorp/golang-lru"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
path "github.com/ipfs/go-path"
opts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
isd "github.com/jbenet/go-is-domain"
ci "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer"
routing "github.com/libp2p/go-libp2p-core/routing"
mh "github.com/multiformats/go-multihash"
)

// mpns (a multi-protocol NameSystem) implements generic IPFS naming.
Expand Down Expand Up @@ -112,12 +112,12 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.
}

// Resolver selection:
// 1. if it is a multihash resolve through "ipns".
// 1. if it is a CID/multihash resolve through "ipns".
// 2. if it is a domain name, resolve through "dns"
// 3. otherwise resolve through the "proquint" resolver

var res resolver
if _, err := mh.FromB58String(key); err == nil {
if _, err := cid.Decode(key); err == nil {
res = ns.ipnsResolver
} else if isd.IsDomain(key) {
res = ns.dnsResolver
Expand Down

0 comments on commit ef00a67

Please sign in to comment.