Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose muxer ids #2012

Merged
merged 4 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var DefaultSecurity = ChainOptions(
//
// Use this option when you want to *extend* the set of multiplexers used by
// libp2p instead of replacing them.
var DefaultMuxers = Muxer("/yamux/1.0.0", yamux.DefaultTransport)
var DefaultMuxers = Muxer(yamux.ID, yamux.DefaultTransport)

// DefaultTransports are the default libp2p transports.
//
Expand Down
3 changes: 1 addition & 2 deletions libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ func ChainOptions(opts ...Option) Option {
// transport protocols;
//
// - If no multiplexer configuration is provided, the node is configured by
// default to use the "yamux/1.0.0" and "mplux/6.7.0" stream connection
// multiplexers;
// default to use yamux;
//
// - If no security transport is provided, the host uses the go-libp2p's noise
// and/or tls encrypted transport to encrypt all traffic;
Expand Down
2 changes: 2 additions & 0 deletions p2p/muxer/mplex/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
// DefaultTransport has default settings for Transport
var DefaultTransport = &Transport{}

const ID = "/mplex/6.7.0"

var _ network.Multiplexer = &Transport{}

// Transport implements mux.Multiplexer that constructs
Expand Down
2 changes: 2 additions & 0 deletions p2p/muxer/yamux/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

var DefaultTransport *Transport

const ID = "/yamux/1.0.0"

func init() {
config := yamux.DefaultConfig()
// We've bumped this to 16MiB as this critically limits throughput.
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/dial_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func makeUpgrader(t *testing.T, n *Swarm) transport.Upgrader {
pk := n.Peerstore().PrivKey(id)
st := insecure.NewWithIdentity(insecure.ID, id, pk)

u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: "/yamux/1.0.0", Muxer: yamux.DefaultTransport}}, nil, nil, nil)
u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: yamux.ID, Muxer: yamux.DefaultTransport}}, nil, nil, nil)
require.NoError(t, err)
return u
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func GenUpgrader(t *testing.T, n *swarm.Swarm, connGater connmgr.ConnectionGater
pk := n.Peerstore().PrivKey(id)
st := insecure.NewWithIdentity(insecure.ID, id, pk)

u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: "/yamux/1.0.0", Muxer: yamux.DefaultTransport}}, nil, nil, connGater, opts...)
u, err := tptu.New([]sec.SecureTransport{st}, []tptu.StreamMuxer{{ID: yamux.ID, Muxer: yamux.DefaultTransport}}, nil, nil, connGater, opts...)
require.NoError(t, err)
return u
}
Expand Down
4 changes: 2 additions & 2 deletions test-plans/cmd/ping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func main() {

switch muxer {
case "yamux":
options = append(options, libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport))
options = append(options, libp2p.Muxer(yamux.ID, yamux.DefaultTransport))
case "mplex":
options = append(options, libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport))
options = append(options, libp2p.Muxer(mplex.ID, mplex.DefaultTransport))
case "quic":
default:
log.Fatalf("Unsupported muxer: %s", muxer)
Expand Down