Closed lidel closed 4 years ago
This PR implements Stage 1: Parse CIDs as peer ID from https://github.com/libp2p/specs/issues/216.
Stage 1: Parse CIDs as peer ID
TL;DR This PR does not change the default text representation of Peer IDs, all we do in Stage 1 is adding support for creating PeerId objects from CIDs.
Stage 1
For a wider context see libp2p/specs/RFC/0001-text-peerid-cid.md, short story is that CID support will enable IPFS project to support /ipns/{cid} in Base32 (https://github.com/ipfs/ipfs/issues/337), enabling things like http://{libp2p-key-as-cidv1b32}.ipns.dweb.link
/ipns/{cid}
http://{libp2p-key-as-cidv1b32}.ipns.dweb.link
This PR adds two functions:
createFromCID
toCIDString
cc https://github.com/ipfs/ipfs/issues/337, https://github.com/libp2p/specs/issues/216, https://github.com/libp2p/specs/pull/209, https://github.com/ipfs/go-ipfs/issues/5287
ping @vasco-santos
@alanshaw any other feedback that you want to provide here? I think we can go with this
Motivation
This PR implements
Stage 1: Parse CIDs as peer ID
from https://github.com/libp2p/specs/issues/216.TL;DR This PR does not change the default text representation of Peer IDs, all we do in
Stage 1
is adding support for creating PeerId objects from CIDs.For a wider context see libp2p/specs/RFC/0001-text-peerid-cid.md, short story is that CID support will enable IPFS project to support
/ipns/{cid}
in Base32 (https://github.com/ipfs/ipfs/issues/337), enabling things likehttp://{libp2p-key-as-cidv1b32}.ipns.dweb.link
Changes
This PR adds two functions:
createFromCID
accepts CID as String|CID|Buffer and creates PeerId from the multihash value inside of ittoCIDString
serializes PeerId multihash into a CIDv1 in Base32 (libp2p RFC 0001)Next
createFromCID
in https://github.com/ipfs/js-ipfs/pull/2566cc https://github.com/ipfs/ipfs/issues/337, https://github.com/libp2p/specs/issues/216, https://github.com/libp2p/specs/pull/209, https://github.com/ipfs/go-ipfs/issues/5287