-
Notifications
You must be signed in to change notification settings - Fork 299
feat: support name.resolve of peerid as cid #1145
Conversation
This is a hacky way to support CIDs when API is go-ipfs 0.4.22 or older (convert toBase58btc before sending) License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
src/name/resolve.js
Outdated
// normalize PeerIDs to Base58btc, so it works with go-ipfs <=0.4.22 | ||
if (typeof (args) === 'string') { | ||
try { | ||
const path = args.split('/') | ||
if (path.length > 2) { | ||
path[2] = multihash.toB58String(new CID(path[2]).multihash) | ||
args = path.join('/') | ||
} | ||
} catch (err) { | ||
// noop | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a better way? :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All we need to do is stringify args
if it is a CID. We will skip the interface-ipfs-core
test here until go-ipfs supports it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't stringify CIDs anywhere else, removed this hack and added TODO to unskip mentioned test when go-ipfs implements this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah interesting, I guess the querystring module calls toString
on the CID then...
Please would you add the updated |
License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
@alanshaw done |
This PR updates to
interface-ipfs-core": "^0.118.0
which includes test for resolving paths with libp2p-key represented as CIDv1 Base32.Open Problem
The problem is that go-ipfs 0.4.22 does not support PeerID as CID, so test added in ipfs-inactive/interface-js-ipfs-core#553 fails:
@alanshaw not sure how to handle this. Wait for go-ipfs v0.5.0? Fixup on the fly in the meantime?A hacky way to support CIDs when API is go-ipfs 0.4.22 or older is to convert toBase58btc before sending. See below.For now we skip cidv1b32 test, added todo to unskip when go-ipfs ships with native support.
closes #1147