From 43f1b0d9af63d9608972abe8284bcbc8c8a98a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 20 Aug 2017 17:57:00 +0200 Subject: [PATCH] init: 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/init.go | 2 ++ repo/config/discovery.go | 2 +- repo/config/profile.go | 5 +++++ test/sharness/t0020-init.sh | 14 ++++++++++++++ test/sharness/t0021-config.sh | 3 ++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 20e15b27f27..8cc2df80c4a 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -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 diff --git a/repo/config/discovery.go b/repo/config/discovery.go index 30c24ea19b3..64f7af64a68 100644 --- a/repo/config/discovery.go +++ b/repo/config/discovery.go @@ -1,7 +1,7 @@ package config type Discovery struct { - MDNS MDNS + MDNS MDNS //Routing sets default daemon routing mode. Routing string diff --git a/repo/config/profile.go b/repo/config/profile.go index 74383cda63f..6aa5f505380 100644 --- a/repo/config/profile.go +++ b/repo/config/profile.go @@ -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 { diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index 697203a9f02..a01c0876334 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -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 diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 5ade07d0326..17bb0930c21 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -45,7 +45,8 @@ CONFIG_SET_JSON_TEST='{ "MDNS": { "Enabled": true, "Interval": 10 - } + }, + "Routing": "dht" }' test_profile_apply_revert() {