Skip to content

How to send a p2p message to a node with specific peer id? #5354

Answered by dariusc93
kamuik16 asked this question in Q&A
Discussion options

You must be logged in to vote

Your solution would likely be to use libp2p-request-response or libp2p-stream for ease of use if youre sending a single message to a specific peer, however you could also use oneshot in your own behaviour or write your own protocol for this. Now if you really want to use gossipsub (for floodsub), you could have each peer have their own dedicated topic that they are subscribed too and publish messages to that specific topic when you are connected to that peer (or to a peer that is subscribed to that topic), or encrypt the message for the intended peer and broadcast it on a common topic that they all would be subscribed too and attempt to decrypt that message (this will require you to figur…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@kamuik16
Comment options

Answer selected by kamuik16
Comment options

You must be logged in to vote
1 reply
@drHuangMHT
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants