1-> K messaging model?

Apart from the pubsub model of communication that libp2p provides, we also needed a 1→K form of communication where one node requests K other nodes for information and each of the K nodes replies independently using a direct 1-1 communication to the requesting node.
(K is a subset of N - the total number of nodes)

I don’t think this can be natively implemented using the pub-sub model since there are no topics which are known beforehand. Hence, to realize this on top of libp2p, we thought each node in the network could implement a random deterministic function to select k nodes (where k is a subset of K). The node then talks to these k nodes directly (1-1) which in turn, in addition to replying to requesting node, also choose their own k nodes from the K (where K is sent as part of the message metadata).

But I had the following question w.r.t this approach -

Will a node reuse its Peer connections (fanout or mesh connections or gossipsub connections)?

Will the messages thus exchanged be added to the message cache implicitly?

your technical inputs will be greatly appreciated and help us make an informed choice.

thanks,
Vishal

I wouldn’t use pubsub for this use case – it would be shoehorned. I would just model this as a libp2p application protocol. When two peers connect, they identify each other and note that they both converse protocol X. Therefore, each starts a stream for protocol X. When peer A needs to collect and aggregate answers from peers X1…Xn, it just sends a request RPC, and the peer responds on the stream.

1 Like