A way to get a list of peers using my service

From @mitar on Sun Jul 10 2016 18:02:18 GMT+0000 (UTC)

Based on Making your own ipfs service, it seems there is no way to ask IPFS for peer IDs of everyone (or at least X number of random) using my service? How can I then bootstrap my service? It would be great if I could say: tell me at least X number of other peers using my service. And then I could communicate with them.


Copied from original issue: https://github.com/ipfs/faq/issues/144

From @lgierth on Sun Jul 10 2016 18:06:11 GMT+0000 (UTC)

There’s not really any service discovery in IPFS yet – we have a few early ideas here: https://github.com/ipfs/notes/issues/15

From @mitar on Tue Mar 21 2017 10:11:26 GMT+0000 (UTC)

I am currently using pubsub feature to get peers of everyone subscribed to a topic used by my service.

could you share the code?

cc @mitar (not sure if discourse notifies the original commenters when there are comments on threads like this one, which was migrated from https://github.com/ipfs/faq/issues/144)

@iain17, sure. It is here: https://github.com/luckychain/lucky/blob/master/src/js/blockchain.js#L776

It is simply calling ipfs.pubsub.peers IPFS API using pubsuc topic as an argument. See here for more information.