default connection manager
@@ -13,6 +13,7 @@ import (
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
tls "github.com/libp2p/go-libp2p-tls"
yamux "github.com/libp2p/go-libp2p-yamux"
+ "github.com/libp2p/go-libp2p/p2p/net/connmgr"
"github.com/libp2p/go-tcp-transport"
ws "github.com/libp2p/go-ws-transport"
"github.com/multiformats/go-multiaddr"
@@ -99,6 +100,16 @@ var DefaultResourceManager = func(cfg *Config) error {
return cfg.Apply(ResourceManager(mgr))
}
+// DefaultConnManager creates a default connection manager
+var DefaultConnectionManager = func(cfg *Config) error {
+ mgr, err := connmgr.NewConnManager(192, 256)
+ if err != nil {
+ return err
+ }
+
+ return cfg.Apply(ConnectionManager(mgr))
+}
+
// Complete list of default options and when to fallback on them.
//
// Please *DON'T* specify default options any other way. Putting this all here
@@ -139,6 +150,10 @@ var defaults = []struct {
fallback: func(cfg *Config) bool { return cfg.ResourceManager == nil },
opt: DefaultResourceManager,
},
+ {
+ fallback: func(cfg *Config) bool { return cfg.ConnManager == nil },
+ opt: DefaultConnectionManager,
+ },
}
// Defaults configures libp2p to use the default options. Can be combined with
