Service Discovery

We can find peers that are serving the same file on IPFS using

echo “$SERVICE_NAME” | ipfs add
and then running
ipfs dht findprov $SERVICE_NAME

Would it be possible for nodes to find other data associated with these peers.
For instance, what if we needed to know the location of another RPC port attached to these peers? (the ones holding this file)

Could we go from these peer ids to additional data attached to these peers?

You can do ipfs id $peerID but I am not sure what “another RPC port” would be. IPFS is not going to figure out if that host has other ports open. The data you see in findprovs has been put on the DHT. You could potentially query the dht for other information if some peer has put it in it (ipfs dht get key).

1 Like

Lets say its just some metadata attached to my peer (an RPC port for example, but this could be anything, like my name).

I can find the name of my peer, and it may have pinned this extra metadata under a unique CID, but how could I find the hash to this additional file? I would need to know the to use (ipfs dht get ) but i don’t know the contents so I dont know the CID.

Your peer will need to advertise that is has that data (i.e. via ipns for example).

1 Like

Ok, claro, something like ipfs name publish .

This has been very slow for me, both resolving, and publishing. I was hoping there might be another way. For something like unique service discovery this probably wouldn’t work.

Maybe PupSub is what you are looking for?

1 Like

It could totally work!

  1. First find the peers serving the service name.
    ipfs dht findprov $SERVICE

  2. Connect to them all:
    ipfs swarm PEER ID

  3. Then subscribe and publish to the same stream ID
    ipfs pubsub $SERVICE

This would create an immediate chat room over the service where everyone is subscribed and connected to that stream.

Would be a pretty cool method of building decentralized chat rooms!

@unconst just a heads up that if you use ipfs pubsub sub $SERVICE that it will do the DHT advertising and findprovs for you automatically as of go-ipfs 0.6.

However, note that peers that newly join a pubsub topic will not receive older messages so you may need to wait a bit after subscribing for the new peers to be found.