From e49d9d9169c8cc7f154b15ab1a4727b6511ae30c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 19 Oct 2017 09:15:12 -0700 Subject: [PATCH] default settings for the connection manager License: MIT Signed-off-by: Jeromy --- core/core.go | 5 ++++- repo/config/init.go | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 760ed7bfb..21f11b0ce 100644 --- a/core/core.go +++ b/core/core.go @@ -271,7 +271,10 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin func constructConnMgr(cfg config.ConnMgr) (ifconnmgr.ConnManager, error) { switch cfg.Type { - case "", "none": + case "": + // 'default' value is the basic connection manager + return connmgr.NewConnManager(config.DefaultConnMgrLowWater, config.DefaultConnMgrHighWater, config.DefaultConnMgrGracePeriod), nil + case "none": return nil, nil case "basic": grace, err := time.ParseDuration(cfg.GracePeriod) diff --git a/repo/config/init.go b/repo/config/init.go index 80923355e..0b3537d25 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "time" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" @@ -71,11 +72,31 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Interval: "12h", Strategy: "all", }, + Swarm: SwarmConfig{ + ConnMgr: ConnMgr{ + LowWater: DefaultConnMgrLowWater, + HighWater: DefaultConnMgrHighWater, + GracePeriod: DefaultConnMgrGracePeriod.String(), + Type: "basic", + }, + }, } return conf, nil } +// DefaultConnMgrHighWater is the default value for the connection managers +// 'high water' mark +const DefaultConnMgrHighWater = 900 + +// DefaultConnMgrLowWater is the default value for the connection managers 'low +// water' mark +const DefaultConnMgrLowWater = 600 + +// DefaultConnMgrGracePeriod is the default value for the connection managers +// grace period +const DefaultConnMgrGracePeriod = time.Second * 20 + // DefaultDatastoreConfig is an internal function exported to aid in testing. func DefaultDatastoreConfig() Datastore { return Datastore{