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
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
As part of the async iterator refactor some peer IDs were being returned as CIDs - the conversion was done in IPFS but not in libp2p, which meant that where IPFS exposes libp2p directly, peer IDs were being returned as strings, e.g. pubsub topic subscribers, message senders, etc.
The aim is to convert these to CIDs in the long run but such a change needs to be driven from inside libp2p instead of piecemeal at the IPFS layer.
This PR changes the `ipfs.id().id` and `ipfs.swarm.peers().[].peer` properties to strings so we can do the CID conversion in one go.
Also adds more in-depth tests for `ipfs.id` and documents the output from that method.
BREAKING CHANGE:
Where `PeerID`s were previously [CID]s, now they are Strings
- `ipfs.bitswap.stat().peers[n]` is now a String (was a CID)
- `ipfs.dht.findPeer().id` is now a String (was a CID)
- `ipfs.dht.findProvs()[n].id` is now a String (was a CID)
- `ipfs.dht.provide()[n].id` is now a String (was a CID)
- `ipfs.dht.put()[n].id` is now a String (was a CID)
- `ipfs.dht.query()[n].id` is now a String (was a CID)
- `ipfs.id().id` is now a String (was a CID)
- `ipfs.id().addresses[n]` are now [Multiaddr]s (were Strings)
[CID]: https://www.npmjs.com/package/cids
[Multiaddr]: https://www.npmjs.com/package/multiaddr
Copy file name to clipboardexpand all lines: SPEC/DHT.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,14 @@ Where `peerId` is a Peer ID in `String`, [`CID`](https://github.com/multiformats
19
19
20
20
| Type | Description |
21
21
| -------- | -------- |
22
-
|`Promise<{ id: CID, addrs: Multiaddr[] }>`| A promise that resolves to an object with `id` and `addrs`. `id` is a [`CID`](https://github.com/multiformats/js-cid) - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
22
+
|`Promise<{ id: String, addrs: Multiaddr[] }>`| A promise that resolves to an object with `id` and `addrs`. `id` is a String - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
@@ -60,7 +60,7 @@ Note that if `options.numProviders` are not found an error will be thrown.
60
60
61
61
| Type | Description |
62
62
| -------- | -------- |
63
-
|`AsyncIterable<{ id: CID, addrs: Multiaddr[] }>`| A async iterable that yields objects with `id` and `addrs`. `id` is a [`CID`](https://github.com/multiformats/js-cid) - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
63
+
|`AsyncIterable<{ id: String, addrs: Multiaddr[] }>`| A async iterable that yields objects with `id` and `addrs`. `id` is a String - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
Copy file name to clipboardexpand all lines: SPEC/SWARM.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -18,15 +18,15 @@
18
18
19
19
| Type | Description |
20
20
| -------- | -------- |
21
-
|`Promise<{ id: CID, addrs: Multiaddr[] }>`| A promise that resolves to an object with `id` and `addrs`. `id` is a [`CID`](https://github.com/multiformats/js-cid) - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
21
+
|`Promise<{ id: String, addrs: Multiaddr[] }>`| A promise that resolves to an object with `id` and `addrs`. `id` is a String - the peer's ID and `addrs` is an array of [Multiaddr](https://github.com/multiformats/js-multiaddr/) - addresses for the peer. |
22
22
23
23
**Example:**
24
24
25
25
```JavaScript
26
26
constpeerInfos=awaitipfs.swarm.addrs()
27
27
28
28
peerInfos.forEach(info=> {
29
-
console.log(info.id.toString())
29
+
console.log(info.id)
30
30
/*
31
31
QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
32
32
*/
@@ -131,7 +131,7 @@ A great source of [examples][] can be found in the tests for this API.
131
131
The returned array has the following form:
132
132
133
133
-`addr: Multiaddr`
134
-
-`peer: CID`
134
+
-`peer: String`
135
135
-`latency: String` - Only if `verbose: true` was passed
136
136
-`muxer: String` - The type of stream muxer the peer is usng
137
137
-`streams: string[]` - Only if `verbose: true`, a list of currently open streams
0 commit comments