go-libp2p
go-libp2p copied to clipboard
Support multiple peers for the "chat-with-mdns" example
The chat-with-mdns example is pretty limited and quite confusing regarding the streams management. As a libp2p beginner, it is not easy to really get the behavior of the StreamHandler and when another stream is opened.
In addition, the input read from Stdin cannot be consumed from the different goroutines which make the example incompatible with a multi peers setup.
In this PR, I propose to store the peers in a distinct struct to later be able to broadcast messages to all the peers part of the p2p network.
Execution example:
Can you also update the example to use the latest version of go-libp2p? Update the examples/go.mod file to use go-libp2p v0.37.
@MqllR can you fix the merge conflict and the go check error:
Error: ./relay/main.go:153:35: network.WithUseTransient is deprecated: Use WithAllowLimitedConn instead. (SA1019)
Merged master which fix the static check (see https://github.com/libp2p/go-libp2p/pull/3023).
Automatically closing old open PRs. If you're still interested in merging this please open the PR again and rebase from the latest master, otherwise do nothing.