config: Fix formatting, missing param check.

Fixed formatting for autopilot config params, as well as added check for
`MaxChannels` param which was presumably a mistaken copypaste from the
`MaxChannelSize' param.
This commit is contained in:
Brenden Matthews 2018-03-22 16:45:37 -04:00
parent bd631a43bb
commit 8a51043462
No known key found for this signature in database
GPG Key ID: 60FBD122E62B0D30

View File

@ -129,7 +129,7 @@ type autoPilotConfig struct {
MaxChannels int `long:"maxchannels" description:"The maximum number of channels that should be created"` MaxChannels int `long:"maxchannels" description:"The maximum number of channels that should be created"`
Allocation float64 `long:"allocation" description:"The percentage of total funds that should be committed to automatic channel establishment"` Allocation float64 `long:"allocation" description:"The percentage of total funds that should be committed to automatic channel establishment"`
MinChannelSize int64 `long:"minchansize" description:"The smallest channel that the autopilot agent should create"` MinChannelSize int64 `long:"minchansize" description:"The smallest channel that the autopilot agent should create"`
MaxChannelSize int64 `long:"maxchansize" description:"The larget channel taht the autopilot agent should create"` MaxChannelSize int64 `long:"maxchansize" description:"The largest channel that the autopilot agent should create"`
} }
type torConfig struct { type torConfig struct {
@ -346,27 +346,27 @@ func loadConfig() (*config, error) {
// Ensure that the user didn't attempt to specify negative values for // Ensure that the user didn't attempt to specify negative values for
// any of the autopilot params. // any of the autopilot params.
if cfg.Autopilot.MaxChannelSize < 0 { if cfg.Autopilot.MaxChannels < 0 {
str := "%s: autopilot.maxchansize must be greater than zero" str := "%s: autopilot.maxchannels must be non-negative"
err := fmt.Errorf(str) err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return nil, err return nil, err
} }
if cfg.Autopilot.Allocation < 0 { if cfg.Autopilot.Allocation < 0 {
str := "%s: autopilot.allocation must be greater than zero" str := "%s: autopilot.allocation must be non-negative"
err := fmt.Errorf(str) err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return nil, err return nil, err
} }
if cfg.Autopilot.MinChannelSize < 0 { if cfg.Autopilot.MinChannelSize < 0 {
str := "%s: autopilot.minchansize must be greater than zero" str := "%s: autopilot.minchansize must be non-negative"
err := fmt.Errorf(str) err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return nil, err return nil, err
} }
if cfg.Autopilot.MaxChannelSize < 0 { if cfg.Autopilot.MaxChannelSize < 0 {
str := "%s: autopilot.maxchansize must be greater than zero" str := "%s: autopilot.maxchansize must be non-negative"
err := fmt.Errorf(str) err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return nil, err return nil, err
} }