You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change adds two functions:
- createFromCID accepts CID as String|CID|Buffer
and creates PeerId from the multihash value inside of it
- toCIDString serializes PeerId multihash into a CIDv1 in Base32,
as agreed in libp2p/specs#209
License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
@@ -145,6 +147,14 @@ Creates a Peer ID from a buffer representing the key's multihash.
145
147
146
148
Returns `PeerId`.
147
149
150
+
### `createFromCID(cid)`
151
+
152
+
-`cid: CID|String|Buffer` - The multihash encoded as [CID](https://github.com/ipld/js-cid) (object, `String` or `Buffer`)
153
+
154
+
Creates a Peer ID from a CID representation of the key's multihash ([RFC 0001](https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md)).
155
+
156
+
Returns `PeerId`.
157
+
148
158
### `createFromB58String(str)`
149
159
150
160
Creates a Peer ID from a Base58 string representing the key's multihash.
@@ -197,6 +207,15 @@ Returns the Peer ID's `id` as a buffer.
197
207
<Buffer 12 20 d6 24 39 98 f2 fc 56 34 3a d7 ed 03 42 ab 78 86 a4 eb 18 d7 36 f1 b6 7d 44 b3 7f cc 81 e0 f3 9f>
198
208
```
199
209
210
+
211
+
### `toCIDString()`
212
+
213
+
Returns the Peer ID's `id` as a self-describing CIDv1 in Base32 ([RFC 0001](https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md))
0 commit comments