From a3f1ea50733694ed20acb4b6f36f4080a64ab1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 31 Oct 2017 19:34:38 +0100 Subject: [PATCH] config: apply review to lowpower profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- cmd/ipfs/daemon.go | 2 +- docs/config.md | 1 - repo/config/config.go | 1 + repo/config/discovery.go | 3 --- repo/config/init.go | 5 ++++- repo/config/profile.go | 8 +++++++- repo/config/routing.go | 6 ++++++ test/sharness/t0020-init.sh | 2 +- test/sharness/t0021-config.sh | 3 +-- 9 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 repo/config/routing.go diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 5b6cd7d2e92..d4ec6f04929 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 cc9e005b2c2..f2d32f7b254 100644 --- a/docs/config.md +++ b/docs/config.md @@ -163,7 +163,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 ac7c1152b77..719170baad8 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 64f7af64a68..4fb8508f00a 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 2cdae21c987..f008cee63b2 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -48,7 +48,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 611ab056b71..9901fab020c 100644 --- a/repo/config/profile.go +++ b/repo/config/profile.go @@ -1,5 +1,7 @@ package config +import "time" + // ConfigProfiles is a map holding configuration transformers var ConfigProfiles = map[string]func(*Config) error{ "server": func(c *Config) error { @@ -54,8 +56,12 @@ var ConfigProfiles = map[string]func(*Config) error{ 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 00000000000..24ac8fabbe1 --- /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 a01c0876334..4dd1d786a4e 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 4877d6a73c0..b7b985a8963 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_config_cmd() {