-
Notifications
You must be signed in to change notification settings - Fork 124
Conversation
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`.
Is ready for re-review? |
Yes, should be good to go. |
@@ -27,14 +27,15 @@ module.exports = (common, options) => { | |||
after(() => common.clean()) | |||
|
|||
it('should find other peers', async () => { | |||
const res = await nodeA.dht.findPeer(nodeB.peerId.id) | |||
|
|||
const nodeBId = await nodeB.id() |
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.
Why not use nodeB.peerId
here?
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.
It's not part of the API defined in interface-js-ipfs-core
so we should really remove it from ipfsd-ctl
return values.
This is my mind wandering from the task in hand though so I'm happy to change it if required.
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.
Right, so it shouldn't be used in the interface tests because we can't guarantee ipfsd-ctl
spawned the node(s) in the test. 👍 Sounds like a good plan, I'm happy to leave this like it is. Do you want to open an issue here to track that task?
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.
Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
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.
Changes here LGTM.
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.
Still good
Also updates all examples to use the new API. Depends on: - [x] ipfs-inactive/interface-js-ipfs-core#581 - [x] ipfs-inactive/js-ipfs-http-client#1226 - [x] libp2p/js-libp2p#545 BREAKING CHANGE: Where `PeerID`s were previously [CID](https://www.npmjs.com/package/cids)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](https://www.npmjs.com/package/multiaddr)s (were Strings)
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
andipfs.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 CIDs, now they are Stringsipfs.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 Multiaddrs (were Strings)