Skip to content

Commit ef00a67

Browse files
committed
feat: resolve peer IDs as CIDs
This adds support for resolving /ipns/<cidv1-libp2p-key> cc #5287 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent 49f768d commit ef00a67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

namesys/namesys.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"time"
77

88
lru "github.com/hashicorp/golang-lru"
9+
cid "github.com/ipfs/go-cid"
910
ds "github.com/ipfs/go-datastore"
1011
path "github.com/ipfs/go-path"
1112
opts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
1213
isd "github.com/jbenet/go-is-domain"
1314
ci "github.com/libp2p/go-libp2p-core/crypto"
1415
peer "github.com/libp2p/go-libp2p-core/peer"
1516
routing "github.com/libp2p/go-libp2p-core/routing"
16-
mh "github.com/multiformats/go-multihash"
1717
)
1818

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

114114
// Resolver selection:
115-
// 1. if it is a multihash resolve through "ipns".
115+
// 1. if it is a CID/multihash resolve through "ipns".
116116
// 2. if it is a domain name, resolve through "dns"
117117
// 3. otherwise resolve through the "proquint" resolver
118118

119119
var res resolver
120-
if _, err := mh.FromB58String(key); err == nil {
120+
if _, err := cid.Decode(key); err == nil {
121121
res = ns.ipnsResolver
122122
} else if isd.IsDomain(key) {
123123
res = ns.dnsResolver

0 commit comments

Comments
 (0)