mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
config: extract default config into function
To make it easy to extract the configuration parsing out of the main package, the default config is exported as its own function.
This commit is contained in:
parent
9ed1cd623f
commit
d4d10b5c71
25
config.go
25
config.go
@ -289,16 +289,9 @@ type Config struct {
|
||||
AllowCircularRoute bool `long:"allow-circular-route" description:"If true, our node will allow htlc forwards that arrive and depart on the same channel."`
|
||||
}
|
||||
|
||||
// LoadConfig initializes and parses the config using a config file and command
|
||||
// line options.
|
||||
//
|
||||
// The configuration proceeds as follows:
|
||||
// 1) Start with a default config with sane settings
|
||||
// 2) Pre-parse the command line to check for an alternative config file
|
||||
// 3) Load configuration file overwriting defaults with any specified options
|
||||
// 4) Parse CLI options and overwrite/add any specified options
|
||||
func LoadConfig() (*Config, error) {
|
||||
defaultCfg := Config{
|
||||
// DefaultConfig returns all default values for the Config struct.
|
||||
func DefaultConfig() Config {
|
||||
return Config{
|
||||
LndDir: defaultLndDir,
|
||||
ConfigFile: defaultConfigFile,
|
||||
DataDir: defaultDataDir,
|
||||
@ -397,10 +390,20 @@ func LoadConfig() (*Config, error) {
|
||||
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
|
||||
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadConfig initializes and parses the config using a config file and command
|
||||
// line options.
|
||||
//
|
||||
// The configuration proceeds as follows:
|
||||
// 1) Start with a default config with sane settings
|
||||
// 2) Pre-parse the command line to check for an alternative config file
|
||||
// 3) Load configuration file overwriting defaults with any specified options
|
||||
// 4) Parse CLI options and overwrite/add any specified options
|
||||
func LoadConfig() (*Config, error) {
|
||||
// Pre-parse the command line options to pick up an alternative config
|
||||
// file.
|
||||
preCfg := defaultCfg
|
||||
preCfg := DefaultConfig()
|
||||
if _, err := flags.Parse(&preCfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user