mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
config: apply review to lowpower profile
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
@ -151,7 +151,6 @@ Headers.
|
|||||||
Options: []cmdkit.Option{
|
Options: []cmdkit.Option{
|
||||||
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
|
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
|
||||||
cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
|
cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
|
||||||
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
|
|
||||||
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("default"),
|
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("default"),
|
||||||
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
|
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
|
||||||
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
|
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
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routingOption = cfg.Discovery.Routing
|
routingOption = cfg.Routing.Type
|
||||||
if routingOption == "" {
|
if routingOption == "" {
|
||||||
routingOption = routingOptionDHTKwd
|
routingOption = routingOptionDHTKwd
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ Available profiles:
|
|||||||
'test' - Reduces external interference of IPFS daemon, this
|
'test' - Reduces external interference of IPFS daemon, this
|
||||||
is useful when using the daemon in test environments.
|
is useful when using the daemon in test environments.
|
||||||
'lowpower' - Reduces daemon overhead on the system. May affect node
|
'lowpower' - Reduces daemon overhead on the system. May affect node
|
||||||
functionality.
|
functionality - performance of content discovery and data fetching
|
||||||
|
may be degraded.
|
||||||
|
|
||||||
ipfs uses a repository in the local file system. By default, the repo is
|
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
|
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
|
||||||
|
@ -203,7 +203,6 @@ Valid modes are:
|
|||||||
- `dht` (default)
|
- `dht` (default)
|
||||||
- `dhtclient`
|
- `dhtclient`
|
||||||
- `none`
|
- `none`
|
||||||
- `supernode` (deprecated)
|
|
||||||
|
|
||||||
## `Gateway`
|
## `Gateway`
|
||||||
Options for the HTTP gateway.
|
Options for the HTTP gateway.
|
||||||
|
@ -19,6 +19,7 @@ type Config struct {
|
|||||||
Addresses Addresses // local node's addresses
|
Addresses Addresses // local node's addresses
|
||||||
Mounts Mounts // local node's mount points
|
Mounts Mounts // local node's mount points
|
||||||
Discovery Discovery // local node's discovery mechanisms
|
Discovery Discovery // local node's discovery mechanisms
|
||||||
|
Routing Routing // local node's routing settings
|
||||||
Ipns Ipns // Ipns settings
|
Ipns Ipns // Ipns settings
|
||||||
Bootstrap []string // local nodes's bootstrap peer addresses
|
Bootstrap []string // local nodes's bootstrap peer addresses
|
||||||
Gateway Gateway // local node's gateway server options
|
Gateway Gateway // local node's gateway server options
|
||||||
|
@ -2,9 +2,6 @@ package config
|
|||||||
|
|
||||||
type Discovery struct {
|
type Discovery struct {
|
||||||
MDNS MDNS
|
MDNS MDNS
|
||||||
|
|
||||||
//Routing sets default daemon routing mode.
|
|
||||||
Routing string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MDNS struct {
|
type MDNS struct {
|
||||||
|
@ -43,7 +43,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
Interval: 10,
|
Interval: 10,
|
||||||
},
|
},
|
||||||
Routing: "dht",
|
},
|
||||||
|
|
||||||
|
Routing: Routing{
|
||||||
|
Type: "dht",
|
||||||
},
|
},
|
||||||
|
|
||||||
// setup the node mount points.
|
// setup the node mount points.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
// Transformer is a function which takes configuration and applies some filter to it
|
// Transformer is a function which takes configuration and applies some filter to it
|
||||||
type Transformer func(c *Config) error
|
type Transformer func(c *Config) error
|
||||||
|
|
||||||
@ -74,8 +76,12 @@ var Profiles = map[string]Transformer{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
"lowpower": func(c *Config) error {
|
"lowpower": func(c *Config) error {
|
||||||
c.Discovery.Routing = "dhtclient"
|
c.Routing.Type = "dhtclient"
|
||||||
c.Reprovider.Interval = "0"
|
c.Reprovider.Interval = "0"
|
||||||
|
|
||||||
|
c.Swarm.ConnMgr.LowWater = 20
|
||||||
|
c.Swarm.ConnMgr.HighWater = 40
|
||||||
|
c.Swarm.ConnMgr.GracePeriod = time.Minute.String()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
7
repo/config/routing.go
Normal file
7
repo/config/routing.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
// Routing defines configuration options for libp2p routing
|
||||||
|
type Routing struct {
|
||||||
|
// Type sets default daemon routing mode.
|
||||||
|
Type string
|
||||||
|
}
|
@ -168,17 +168,17 @@ test_expect_success "clean up ipfs dir" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "'ipfs init --profile=lowpower' succeeds" '
|
test_expect_success "'ipfs init --profile=lowpower' succeeds" '
|
||||||
BITS="1024" &&
|
BITS="1024" &&
|
||||||
ipfs init --bits="$BITS" --profile=lowpower
|
ipfs init --bits="$BITS" --profile=lowpower
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "'ipfs config Discovery.Routing' looks good" '
|
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"
|
test $(cat actual_config) = "dhtclient"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "clean up ipfs dir" '
|
test_expect_success "clean up ipfs dir" '
|
||||||
rm -rf "$IPFS_PATH"
|
rm -rf "$IPFS_PATH"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_init_ipfs
|
test_init_ipfs
|
||||||
|
@ -45,8 +45,7 @@ CONFIG_SET_JSON_TEST='{
|
|||||||
"MDNS": {
|
"MDNS": {
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Interval": 10
|
"Interval": 10
|
||||||
},
|
}
|
||||||
"Routing": "dht"
|
|
||||||
}'
|
}'
|
||||||
|
|
||||||
test_profile_apply_revert() {
|
test_profile_apply_revert() {
|
||||||
|
Reference in New Issue
Block a user