init: lowpower profile
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Aug 20, 2017 at 17:57 UTC
fae9967a0375bd8cadac6ef374d33b6f5a04f106
5 files changed
+24
-2
cmd/ipfs/init.go
+2
@@ -39,6 +39,8 @@ Available profiles:
39
running IPFS on machines with public IPv4 addresses.
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.
44
45
ipfs uses a repository in the local file system. By default, the repo is
46
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
repo/config/discovery.go
+1
-1
@@ -1,7 +1,7 @@
1
package config
2
3
type Discovery struct {
4
- MDNS MDNS
4
+ MDNS MDNS
5
6
//Routing sets default daemon routing mode.
7
Routing string
repo/config/profile.go
+5
@@ -73,6 +73,11 @@ var Profiles = map[string]Transformer{
73
c.Datastore.Spec = DefaultDatastoreConfig().Spec
74
return nil
75
},
76
+ "lowpower": func(c *Config) error {
77
+ c.Discovery.Routing = "dhtclient"
78
+ c.Reprovider.Interval = "0"
79
+ return nil
80
+ },
81
}
82
83
func appendSingle(a []string, b []string) []string {
test/sharness/t0020-init.sh
+14
@@ -167,6 +167,20 @@ test_expect_success "clean up ipfs dir" '
167
rm -rf "$IPFS_PATH"
168
'
169
170
+test_expect_success "'ipfs init --profile=lowpower' succeeds" '
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"
178
+'
179
+
180
+test_expect_success "clean up ipfs dir" '
181
+ rm -rf "$IPFS_PATH"
182
+'
183
+
184
test_init_ipfs
185
186
test_launch_ipfs_daemon
test/sharness/t0021-config.sh
+2
-1
@@ -45,7 +45,8 @@ CONFIG_SET_JSON_TEST='{
45
"MDNS": {
46
"Enabled": true,
47
"Interval": 10
48
- }
48
+ },
49
+ "Routing": "dht"
50
}'
51
52
test_profile_apply_revert() {