Communication
In this section, we'll focus on how peers communicate with one another. Once peers are in the subnet and connected to the cluster of nodes from the bootstrap node, they need a way to communicate with one another. There are two main ways to communicate: using a GossipSub, a direct P2P stream using a custom protocol, or a direct P2P stream using the API protocol.
Most communication should be done via a gossip protocol. A gossip protocol is a message distribution system for distributed networks. In a GossipSub, when a peer broadcasts a message, all other peers that should get that message receive it, such as all of the peers, certain roles, or subsets of peers.
Direct P2P Protocols
Communication can be done directly between two peers by opening a stream between the peers. This can be done by building a custom P2P protocol purpose-built for the use case, or by using the API protocol.
Build a custom protocol for communication requirements where the task or data is located in the same process as the subnet template.
For use cases where a peer is running multiple processes, such as LLMs being hosted on multiple servers, use the API Protocol.
Building a custom protocol is for use cases for communication, where a peer may want to get data from specific peers; they can contact them directly via a custom protocol.
The API protocol is a prebuilt protocol that is best for use cases where a peer's business logic is in a separate process, local or remote. The API protocol is set up so that when a peer is called by another peer, the peer that is called will make an API request to a separate process hosting an API based on the API configuration.
Last updated