diff --git a/p2p/net/swarm/swarm.go b/p2p/net/swarm/swarm.go index a3787ced..05eecec5 100644 --- a/p2p/net/swarm/swarm.go +++ b/p2p/net/swarm/swarm.go @@ -109,8 +109,11 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, return nil, err } - wrap := func(c transport.Conn) transport.Conn { - return mconn.WrapConn(bwc, c) + var wrap func(c transport.Conn) transport.Conn + if bwc != nil { + wrap = func(c transport.Conn) transport.Conn { + return mconn.WrapConn(bwc, c) + } } s := &Swarm{