Skip to content

Commit ecf2b6a

Browse files
committed
init: lowpower profile
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent e9d2817 commit ecf2b6a

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

cmd/ipfs/init.go

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Available profiles:
3636
running IPFS on machines with public IPv4 addresses.
3737
'test' - Reduces external interference of IPFS daemon, this
3838
is useful when using the daemon in test environments.
39+
'lowpower' - Reduces daemon overhead on the system. May affect node
40+
functionality.
3941
4042
ipfs uses a repository in the local file system. By default, the repo is
4143
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH

repo/config/discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package config
22

33
type Discovery struct {
4-
MDNS MDNS
4+
MDNS MDNS
55

66
//Routing sets default daemon routing mode.
77
Routing string

repo/config/profile.go

+5
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ var ConfigProfiles = map[string]func(*Config) error{
4141
c.Discovery.MDNS.Enabled = false
4242
return nil
4343
},
44+
"lowpower": func(c *Config) error {
45+
c.Discovery.Routing = "dhtclient"
46+
c.Reprovider.Interval = "0"
47+
return nil
48+
},
4449
}

test/sharness/t0020-init.sh

+14
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,20 @@ test_expect_success "clean up ipfs dir" '
167167
rm -rf "$IPFS_PATH"
168168
'
169169

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+
170184
test_init_ipfs
171185

172186
test_launch_ipfs_daemon

test/sharness/t0021-config.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ CONFIG_SET_JSON_TEST='{
4545
"MDNS": {
4646
"Enabled": true,
4747
"Interval": 10
48-
}
48+
},
49+
"Routing": "dht"
4950
}'
5051

5152
test_config_cmd() {

0 commit comments

Comments
 (0)