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 <[email protected]>
  • 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.