libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
309 stars 178 forks source link

Is it possible to publish a message on a topic only for specific peers? #532

Open iowar opened 1 year ago

iowar commented 1 year ago

I wonder if this is possible, and if not, what alternative filters can be applied?

Stebalien commented 1 year ago

Not really. If you want to send messages directly from one peer to another, I'd recommend opening a new stream to that peer and sending it directly. Pubsub is a broadcast protocol; it tries to maintain a well connected graph for distributing messages, but there isn't even a guarantee that you'll be connected to any specific peer.

iowar commented 1 year ago

Thank you for the quick response I get it. I have another question. Is it possible to use this part as an authentication mechanism with the ConnectionGater structure? At this stage, the system hasn't established a complete connection yet, and it seems that we cannot create a stream. Apart from the public key verification, it doesn't seem like much else can be done.It would be great to have something that enables one-way data transmission at this stage.Perhaps I shouldn't have asked this question in the pubsub repository, I'm not sure.