Expose muxer ids (#2012)

* docs: remove documentation indicating that mplex is enabled by default

* feat: expose yamux ID as a constant

* feat: expose mplex ID as a constant

* reword muxer config documentation

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
Adin Schmahmann 2023-01-25 15:53:43 -08:00 committed by GitHub
parent 084de0692a
commit d5a280e6f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 7 deletions

View File

@ -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.
//

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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
}

View File

@ -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
}

View File

@ -102,9 +102,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)