Skip to content

Commit af9b4af

Browse files
committed
config: apply review to lowpower profile
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent fae9967 commit af9b4af

File tree

10 files changed

+28
-16
lines changed

10 files changed

+28
-16
lines changed

cmd/ipfs/daemon.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ Headers.
151151
Options: []cmdkit.Option{
152152
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
153153
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"),
155154
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("default"),
156155
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
157156
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
313312
return
314313
}
315314

316-
routingOption = cfg.Discovery.Routing
315+
routingOption = cfg.Routing.Type
317316
if routingOption == "" {
318317
routingOption = routingOptionDHTKwd
319318
}

cmd/ipfs/init.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Available profiles:
4040
'test' - Reduces external interference of IPFS daemon, this
4141
is useful when using the daemon in test environments.
4242
'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.
4445
4546
ipfs uses a repository in the local file system. By default, the repo is
4647
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH

docs/config.md

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ Valid modes are:
203203
- `dht` (default)
204204
- `dhtclient`
205205
- `none`
206-
- `supernode` (deprecated)
207206

208207
## `Gateway`
209208
Options for the HTTP gateway.

repo/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Config struct {
1919
Addresses Addresses // local node's addresses
2020
Mounts Mounts // local node's mount points
2121
Discovery Discovery // local node's discovery mechanisms
22+
Routing Routing // local node's routing settings
2223
Ipns Ipns // Ipns settings
2324
Bootstrap []string // local nodes's bootstrap peer addresses
2425
Gateway Gateway // local node's gateway server options

repo/config/discovery.go

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package config
22

33
type Discovery struct {
44
MDNS MDNS
5-
6-
//Routing sets default daemon routing mode.
7-
Routing string
85
}
96

107
type MDNS struct {

repo/config/init.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
4343
Enabled: true,
4444
Interval: 10,
4545
},
46-
Routing: "dht",
46+
},
47+
48+
Routing: Routing{
49+
Type: "dht",
4750
},
4851

4952
// setup the node mount points.

repo/config/profile.go

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

3+
import "time"
4+
35
// Transformer is a function which takes configuration and applies some filter to it
46
type Transformer func(c *Config) error
57

@@ -74,8 +76,12 @@ var Profiles = map[string]Transformer{
7476
return nil
7577
},
7678
"lowpower": func(c *Config) error {
77-
c.Discovery.Routing = "dhtclient"
79+
c.Routing.Type = "dhtclient"
7880
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()
7985
return nil
8086
},
8187
}

repo/config/routing.go

+7
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,17 @@ test_expect_success "clean up ipfs dir" '
168168
'
169169

170170
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
173173
'
174174

175175
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"
178178
'
179179

180180
test_expect_success "clean up ipfs dir" '
181-
rm -rf "$IPFS_PATH"
181+
rm -rf "$IPFS_PATH"
182182
'
183183

184184
test_init_ipfs

test/sharness/t0021-config.sh

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

5251
test_profile_apply_revert() {

0 commit comments

Comments
 (0)