@cryptotaxi247 / kubo / commits / e49d9d916

default settings for the connection manager

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Oct 19, 2017 at 09:15 UTC e49d9d9169c8cc7f154b15ab1a4727b6511ae30c
2 files changed +25 -1
core/core.go
+4 -1
@@ -271,7 +271,10 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
271
272 func constructConnMgr(cfg config.ConnMgr) (ifconnmgr.ConnManager, error) {
273 switch cfg.Type {
274 - case "", "none":
274 + case "":
275 + // 'default' value is the basic connection manager
276 + return connmgr.NewConnManager(config.DefaultConnMgrLowWater, config.DefaultConnMgrHighWater, config.DefaultConnMgrGracePeriod), nil
277 + case "none":
278 return nil, nil
279 case "basic":
280 grace, err := time.ParseDuration(cfg.GracePeriod)
repo/config/init.go
+21
@@ -5,6 +5,7 @@ import (
5 "errors"
6 "fmt"
7 "io"
8 + "time"
9
10 peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer"
11 ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
@@ -71,11 +72,31 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
72 Interval: "12h",
73 Strategy: "all",
74 },
75 + Swarm: SwarmConfig{
76 + ConnMgr: ConnMgr{
77 + LowWater: DefaultConnMgrLowWater,
78 + HighWater: DefaultConnMgrHighWater,
79 + GracePeriod: DefaultConnMgrGracePeriod.String(),
80 + Type: "basic",
81 + },
82 + },
83 }
84
85 return conf, nil
86 }
87
88 +// DefaultConnMgrHighWater is the default value for the connection managers
89 +// 'high water' mark
90 +const DefaultConnMgrHighWater = 900
91 +
92 +// DefaultConnMgrLowWater is the default value for the connection managers 'low
93 +// water' mark
94 +const DefaultConnMgrLowWater = 600
95 +
96 +// DefaultConnMgrGracePeriod is the default value for the connection managers
97 +// grace period
98 +const DefaultConnMgrGracePeriod = time.Second * 20
99 +
100 // DefaultDatastoreConfig is an internal function exported to aid in testing.
101 func DefaultDatastoreConfig() Datastore {
102 return Datastore{