diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 7c427fb6642a..a6e023b95f8f 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -312,7 +312,7 @@ func daemonFunc(req cmds.Request, re cmds.ResponseEmitter) { return } - routingOption = cfg.Discovery.Routing + routingOption = cfg.Routing.Type if routingOption == "" { routingOption = routingOptionDHTKwd } diff --git a/docs/config.md b/docs/config.md index 1e21aaf771b6..e89a8fc9fd5f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -203,7 +203,6 @@ Valid modes are: - `dht` (default) - `dhtclient` - `none` - - `supernode` (deprecated) ## `Gateway` Options for the HTTP gateway. diff --git a/repo/config/config.go b/repo/config/config.go index ac7c1152b777..719170baad8f 100644 --- a/repo/config/config.go +++ b/repo/config/config.go @@ -19,6 +19,7 @@ type Config struct { Addresses Addresses // local node's addresses Mounts Mounts // local node's mount points Discovery Discovery // local node's discovery mechanisms + Routing Routing // local node's routing settings Ipns Ipns // Ipns settings Bootstrap []string // local nodes's bootstrap peer addresses Gateway Gateway // local node's gateway server options diff --git a/repo/config/discovery.go b/repo/config/discovery.go index 64f7af64a682..4fb8508f00a6 100644 --- a/repo/config/discovery.go +++ b/repo/config/discovery.go @@ -2,9 +2,6 @@ package config type Discovery struct { MDNS MDNS - - //Routing sets default daemon routing mode. - Routing string } type MDNS struct { diff --git a/repo/config/init.go b/repo/config/init.go index e34960c62e52..ae727981a322 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -38,7 +38,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { Enabled: true, Interval: 10, }, - Routing: "dht", + }, + + Routing: Routing{ + Type: "dht", }, // setup the node mount points. diff --git a/repo/config/profile.go b/repo/config/profile.go index 6aa5f5053806..b20382ef4ed8 100644 --- a/repo/config/profile.go +++ b/repo/config/profile.go @@ -1,5 +1,7 @@ package config +import "time" + // Transformer is a function which takes configuration and applies some filter to it type Transformer func(c *Config) error @@ -74,8 +76,12 @@ var Profiles = map[string]Transformer{ return nil }, "lowpower": func(c *Config) error { - c.Discovery.Routing = "dhtclient" + c.Routing.Type = "dhtclient" c.Reprovider.Interval = "0" + + c.Swarm.ConnMgr.LowWater = 20 + c.Swarm.ConnMgr.HighWater = 40 + c.Swarm.ConnMgr.GracePeriod = time.Minute.String() return nil }, } diff --git a/repo/config/routing.go b/repo/config/routing.go new file mode 100644 index 000000000000..24ac8fabbe12 --- /dev/null +++ b/repo/config/routing.go @@ -0,0 +1,6 @@ +package config + +type Routing struct { + // Type sets default daemon routing mode. + Type string +} diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index a01c08763341..4dd1d786a4e2 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -173,7 +173,7 @@ test_expect_success "'ipfs init --profile=lowpower' succeeds" ' ' test_expect_success "'ipfs config Discovery.Routing' looks good" ' - ipfs config Discovery.Routing > actual_config && + ipfs config Routing.Type > actual_config && test $(cat actual_config) = "dhtclient" ' diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 17bb0930c211..5ade07d0326a 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -45,8 +45,7 @@ CONFIG_SET_JSON_TEST='{ "MDNS": { "Enabled": true, "Interval": 10 - }, - "Routing": "dht" + } }' test_profile_apply_revert() {