Skip to content

Commit

Permalink
config: apply review to 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 Dec 12, 2017
1 parent 52c3dfa commit a3f1ea5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func daemonFunc(req cmds.Request, re cmds.ResponseEmitter) {
return
}

routingOption = cfg.Discovery.Routing
routingOption = cfg.Routing.Type
if routingOption == "" {
routingOption = routingOptionDHTKwd
}
Expand Down
1 change: 0 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ Valid modes are:
- `dht` (default)
- `dhtclient`
- `none`
- `supernode` (deprecated)

## `Gateway`
Options for the HTTP gateway.
Expand Down
1 change: 1 addition & 0 deletions repo/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Config struct {
Addresses Addresses // local node's addresses
Mounts Mounts // local node's mount points
Discovery Discovery // local node's discovery mechanisms
Routing Routing // local node's routing settings
Ipns Ipns // Ipns settings
Bootstrap []string // local nodes's bootstrap peer addresses
Gateway Gateway // local node's gateway server options
Expand Down
3 changes: 0 additions & 3 deletions repo/config/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package config

type Discovery struct {
MDNS MDNS

//Routing sets default daemon routing mode.
Routing string
}

type MDNS struct {
Expand Down
5 changes: 4 additions & 1 deletion repo/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
Enabled: true,
Interval: 10,
},
Routing: "dht",
},

Routing: Routing{
Type: "dht",
},

// setup the node mount points.
Expand Down
8 changes: 7 additions & 1 deletion repo/config/profile.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package config

import "time"

// ConfigProfiles is a map holding configuration transformers
var ConfigProfiles = map[string]func(*Config) error{
"server": func(c *Config) error {
Expand Down Expand Up @@ -54,8 +56,12 @@ var ConfigProfiles = map[string]func(*Config) error{
return nil
},
"lowpower": func(c *Config) error {
c.Discovery.Routing = "dhtclient"
c.Routing.Type = "dhtclient"
c.Reprovider.Interval = "0"

c.Swarm.ConnMgr.LowWater = 20
c.Swarm.ConnMgr.HighWater = 40
c.Swarm.ConnMgr.GracePeriod = time.Minute.String()
return nil
},
}
6 changes: 6 additions & 0 deletions repo/config/routing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package config

type Routing struct {
// Type sets default daemon routing mode.
Type string
}
2 changes: 1 addition & 1 deletion test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ test_expect_success "'ipfs init --profile=lowpower' succeeds" '
'

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

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

test_config_cmd() {
Expand Down

0 comments on commit a3f1ea5

Please sign in to comment.