How to find remote peer's PeerInfo from PeerId?

Hi everyone,

I’m trying to achieve a basic use case, targeted to run with js-ipfs in the browser, which is: discovering a remote node PeerInfo (~known multiaddresses list) from its PeerId.

The ipfs.dht.findProv returns a list of nodes able to provide requested content/hash.
So, after I played a little with the Go CLI, I naively thought the findPeer method would return multiaddresses lists from the DHT, basically doing the following:

  1. check if one of the already connected peers match the desired PeerId and return its PeerInfo
  2. if not found, query the DHT with the desired PeerId (with timeout and maxNumProvider like optionnal arguments)
  3. DHT nodes member with a connected peer matching desired PeerId return a response with their known PeerInfo of that node

The ipfs.dht.findPeer specification explains the seeked node needs to be reachable, but it seems it’s more than that as it fails if the desired remote node is not already connected/part of the swarm…which cover only the first point of the use case.

Is there a way I could achieve my use case right now?

Thanks for any contribution :slight_smile:

PS: I’m testing with the 0.35.0-rc.0 version. I know there’s still some problems with the maximum number of connected peers threshold being overwhelmed.

1 Like