From a3a4cf97f422ebaa6d6538a3ca1dfd0f6cb9caf7 Mon Sep 17 00:00:00 2001 From: Dmitry Shipenok Date: Thu, 18 Jan 2018 14:17:22 +0300 Subject: [PATCH] Added default muxer in case when none was provided. Should fix 'echo' example. --- libp2p.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libp2p.go b/libp2p.go index 837f9fddf..333bbe1d5 100644 --- a/libp2p.go +++ b/libp2p.go @@ -180,13 +180,19 @@ func newWithCfg(ctx context.Context, cfg *Config) (host.Host, error) { ps = pstore.NewPeerstore() } + // Set default muxer if none was passed in + muxer := cfg.Muxer + if muxer == nil { + muxer = DefaultMuxer() + } + // If secio is disabled, don't add our private key to the peerstore if !cfg.DisableSecio { ps.AddPrivKey(pid, cfg.PeerKey) ps.AddPubKey(pid, cfg.PeerKey.GetPublic()) } - swrm, err := swarm.NewSwarmWithProtector(ctx, cfg.ListenAddrs, pid, ps, cfg.Protector, cfg.Muxer, cfg.Reporter) + swrm, err := swarm.NewSwarmWithProtector(ctx, cfg.ListenAddrs, pid, ps, cfg.Protector, muxer, cfg.Reporter) if err != nil { return nil, err }