Skip to content

Commit

Permalink
init: lowpower profile
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Jan 22, 2018
1 parent c66be07 commit 43f1b0d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Available profiles:
running IPFS on machines with public IPv4 addresses.
'test' - Reduces external interference of IPFS daemon, this
is useful when using the daemon in test environments.
'lowpower' - Reduces daemon overhead on the system. May affect node
functionality.
ipfs uses a repository in the local file system. By default, the repo is
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
Expand Down
2 changes: 1 addition & 1 deletion repo/config/discovery.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

type Discovery struct {
MDNS MDNS
MDNS MDNS

//Routing sets default daemon routing mode.
Routing string
Expand Down
5 changes: 5 additions & 0 deletions repo/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ var Profiles = map[string]Transformer{
c.Datastore.Spec = DefaultDatastoreConfig().Spec
return nil
},
"lowpower": func(c *Config) error {
c.Discovery.Routing = "dhtclient"
c.Reprovider.Interval = "0"
return nil
},
}

func appendSingle(a []string, b []string) []string {
Expand Down
14 changes: 14 additions & 0 deletions test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ test_expect_success "clean up ipfs dir" '
rm -rf "$IPFS_PATH"
'

test_expect_success "'ipfs init --profile=lowpower' succeeds" '
BITS="1024" &&
ipfs init --bits="$BITS" --profile=lowpower
'

test_expect_success "'ipfs config Discovery.Routing' looks good" '
ipfs config Discovery.Routing > actual_config &&
test $(cat actual_config) = "dhtclient"
'

test_expect_success "clean up ipfs dir" '
rm -rf "$IPFS_PATH"
'

test_init_ipfs

test_launch_ipfs_daemon
Expand Down
3 changes: 2 additions & 1 deletion test/sharness/t0021-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ CONFIG_SET_JSON_TEST='{
"MDNS": {
"Enabled": true,
"Interval": 10
}
},
"Routing": "dht"
}'

test_profile_apply_revert() {
Expand Down

0 comments on commit 43f1b0d

Please sign in to comment.