Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: allow passing the id of a network peer to ipfs.id #3386

Merged
merged 7 commits into from
May 13, 2021

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Nov 12, 2020

Adds parity with go-IPFS and allows looking up known peer IDs using
the `ipfs.id` command.
@achingbrain achingbrain added the status/blocked Unable to be worked further until needs are met label Nov 12, 2020
@lidel lidel added status/in-progress In progress and removed status/blocked Unable to be worked further until needs are met labels Apr 12, 2021
@lidel lidel added this to In Review in Maintenance Priorities - Go via automation Apr 12, 2021
Copy link
Contributor

@Gozala Gozala left a 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.

packages/ipfs-core/src/components/id.js Outdated Show resolved Hide resolved
id = PeerId.createFromB58String(options.peerId.toString())
}

if (!libp2p) {
Copy link
Contributor

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

  1. Throw if libp2p isn't running regardless of your other id
  2. 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.

Copy link
Member Author

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.

Copy link
Contributor

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

@BigLep BigLep removed this from In Review in Maintenance Priorities - Go May 10, 2021
@BigLep BigLep added this to In Review in Maintenance Priorities - JS via automation May 10, 2021
@achingbrain achingbrain merged commit 00fd709 into master May 13, 2021
@achingbrain achingbrain deleted the feat/support-peer-id-arg-to-ipfs-id branch May 13, 2021 13:55
Maintenance Priorities - JS automation moved this from In Review to Done May 13, 2021
SgtPooki referenced this pull request in ipfs/js-kubo-rpc-client Aug 18, 2022
Adds parity with go-IPFS and allows looking up known peer IDs using
the `ipfs.id` command.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants