Share known peers between network

Depending on the type/size of data you’re trying to communicate there are different ways about going about this.

Exchanging Small Datasets

If you need to exchange small amount of data and send that across the network to all of your peers, this is something that Gossipsub is ideal for, as it will limit the number of peers you need to connect to, to broadcast to your network. There is an implementation in JS at ChainSafe/gossipsub-js that is close to being finished. You could leverage floodsub in the interim, as the transition should be simple once Gossipsub is ready. Adding https://github.com/libp2p/js-libp2p/blob/v0.25.4/examples/pubsub/1.js#L31-L33 to your node configs will allow you to leverage the libp2p.pubsub endpoints.

Exchanging Larger Datasets

If you need to exchange larger data sets, pubsub is not the way to do this, as it’s very inefficient doing so. However, you can leverage pubsub to notify peers about the existence of the data and then leverage direct connections to pull that data as needed.

1 Like