@cryptotaxi247 / kubo / commits / af9b4af58

config: apply review to lowpower profile

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Oct 31, 2017 at 19:34 UTC af9b4af581dac9e15634d974d4609add0d69c91e
10 files changed +28 -16
cmd/ipfs/daemon.go
+1 -2
@@ -151,7 +151,6 @@ Headers.
151 Options: []cmdkit.Option{
152 cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
153 cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
154 - cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
154 cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("default"),
155 cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
156 cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
@@ -313,7 +312,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
312 return
313 }
314
316 - routingOption = cfg.Discovery.Routing
315 + routingOption = cfg.Routing.Type
316 if routingOption == "" {
317 routingOption = routingOptionDHTKwd
318 }
cmd/ipfs/init.go
+2 -1
@@ -40,7 +40,8 @@ Available profiles:
40 'test' - Reduces external interference of IPFS daemon, this
41 is useful when using the daemon in test environments.
42 'lowpower' - Reduces daemon overhead on the system. May affect node
43 - functionality.
43 + functionality - performance of content discovery and data fetching
44 + may be degraded.
45
46 ipfs uses a repository in the local file system. By default, the repo is
47 located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
docs/config.md
-1
@@ -203,7 +203,6 @@ Valid modes are:
203 - `dht` (default)
204 - `dhtclient`
205 - `none`
206 - - `supernode` (deprecated)
206
207 ## `Gateway`
208 Options for the HTTP gateway.
repo/config/config.go
+1
@@ -19,6 +19,7 @@ type Config struct {
19 Addresses Addresses // local node's addresses
20 Mounts Mounts // local node's mount points
21 Discovery Discovery // local node's discovery mechanisms
22 + Routing Routing // local node's routing settings
23 Ipns Ipns // Ipns settings
24 Bootstrap []string // local nodes's bootstrap peer addresses
25 Gateway Gateway // local node's gateway server options
repo/config/discovery.go
-3
@@ -2,9 +2,6 @@ package config
2
3 type Discovery struct {
4 MDNS MDNS
5 -
6 - //Routing sets default daemon routing mode.
7 - Routing string
5 }
6
7 type MDNS struct {
repo/config/init.go
+4 -1
@@ -43,7 +43,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
43 Enabled: true,
44 Interval: 10,
45 },
46 - Routing: "dht",
46 + },
47 +
48 + Routing: Routing{
49 + Type: "dht",
50 },
51
52 // setup the node mount points.
repo/config/profile.go
+7 -1
@@ -1,5 +1,7 @@
1 package config
2
3 +import "time"
4 +
5 // Transformer is a function which takes configuration and applies some filter to it
6 type Transformer func(c *Config) error
7
@@ -74,8 +76,12 @@ var Profiles = map[string]Transformer{
76 return nil
77 },
78 "lowpower": func(c *Config) error {
77 - c.Discovery.Routing = "dhtclient"
79 + c.Routing.Type = "dhtclient"
80 c.Reprovider.Interval = "0"
81 +
82 + c.Swarm.ConnMgr.LowWater = 20
83 + c.Swarm.ConnMgr.HighWater = 40
84 + c.Swarm.ConnMgr.GracePeriod = time.Minute.String()
85 return nil
86 },
87 }
repo/config/routing.go new
+7
@@ -0,0 +1,7 @@
1 +package config
2 +
3 +// Routing defines configuration options for libp2p routing
4 +type Routing struct {
5 + // Type sets default daemon routing mode.
6 + Type string
7 +}
test/sharness/t0020-init.sh
+5 -5
@@ -168,17 +168,17 @@ test_expect_success "clean up ipfs dir" '
168 '
169
170 test_expect_success "'ipfs init --profile=lowpower' succeeds" '
171 - BITS="1024" &&
172 - ipfs init --bits="$BITS" --profile=lowpower
171 + BITS="1024" &&
172 + ipfs init --bits="$BITS" --profile=lowpower
173 '
174
175 test_expect_success "'ipfs config Discovery.Routing' looks good" '
176 - ipfs config Discovery.Routing > actual_config &&
177 - test $(cat actual_config) = "dhtclient"
176 + ipfs config Routing.Type > actual_config &&
177 + test $(cat actual_config) = "dhtclient"
178 '
179
180 test_expect_success "clean up ipfs dir" '
181 - rm -rf "$IPFS_PATH"
181 + rm -rf "$IPFS_PATH"
182 '
183
184 test_init_ipfs
test/sharness/t0021-config.sh
+1 -2
@@ -45,8 +45,7 @@ CONFIG_SET_JSON_TEST='{
45 "MDNS": {
46 "Enabled": true,
47 "Interval": 10
48 - },
49 - "Routing": "dht"
48 + }
49 }'
50
51 test_profile_apply_revert() {