-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: allow passing the id of a network peer to ipfs.id #3386
Conversation
Adds parity with go-IPFS and allows looking up known peer IDs using the `ipfs.id` command.
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.
Left some comments, but feel free to disregard those.
id = PeerId.createFromB58String(options.peerId.toString()) | ||
} | ||
|
||
if (!libp2p) { |
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.
NIT: 😭 I find inconsistency here really unfortunate. Not having running libp2p is fine if you ask your own addresses / protocols but is an error if you ask some other peer. I think it would be a lot better to either
- Throw if libp2p isn't running regardless of your other id
- Return empty arrays regardless of your other id
Better yet (certainly out of scope here) would be to have APIs that depend on a certain service / capability in namespace which is may or may not be available. That way you can check if (ipfs.network) { ipfs.network.id(...) }
as opposed getting empty arrays or runtime exceptions.
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.
The peer store should work offline, so we should be able to query it for peers we knew about last time we were online.
The implementation here may need a little more thought.
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.
maybe in the short term we should just return empty arrays instead of errors then
Adds parity with go-IPFS and allows looking up known peer IDs using the `ipfs.id` command.
Adds parity with go-IPFS and allows looking up known peer IDs using
the
ipfs.id
command.Depends on: