diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 74e18f381d..4e263bcadb 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -32,7 +32,6 @@ import ( "github.com/ethereum/go-ethereum/contracts/release" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/params" "github.com/naoina/toml" ) @@ -53,15 +52,6 @@ var ( } ) -var defaultNodeConfig = node.Config{ - Name: clientIdentifier, - Version: params.VersionWithCommit(gitCommit), - DataDir: node.DefaultDataDir(), - P2P: p2p.Config{MaxPeers: 25}, - HTTPModules: []string{"eth", "net", "web3"}, - WSModules: []string{"eth", "net", "web3"}, -} - // These settings ensure that TOML keys use the same names as Go struct fields. var tomlSettings = toml.Config{ NormFieldName: func(rt reflect.Type, key string) string { @@ -104,11 +94,20 @@ func loadConfig(file string, cfg *gethConfig) error { return err } +func defaultNodeConfig() node.Config { + cfg := node.DefaultConfig + cfg.Name = clientIdentifier + cfg.Version = params.VersionWithCommit(gitCommit) + cfg.HTTPModules = append(cfg.HTTPModules, "eth") + cfg.WSModules = append(cfg.WSModules, "eth") + return cfg +} + func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { // Load defaults. cfg := gethConfig{ Eth: eth.DefaultConfig, - Node: defaultNodeConfig, + Node: defaultNodeConfig(), } // Load config file. diff --git a/node/defaults.go b/node/defaults.go index bfe257c8e9..519c2d3741 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -21,6 +21,9 @@ import ( "os/user" "path/filepath" "runtime" + + "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/nat" ) const ( @@ -31,6 +34,21 @@ const ( DefaultWSPort = 8546 // Default TCP port for the websocket RPC server ) +// DefaultConfig contains reasonable default settings. +var DefaultConfig = Config{ + DataDir: DefaultDataDir(), + HTTPPort: DefaultHTTPPort, + HTTPModules: []string{"net", "web3"}, + WSPort: DefaultWSPort, + WSModules: []string{"net", "web3"}, + IPCPath: DefaultIPCSocket, + P2P: p2p.Config{ + ListenAddr: ":30303", + MaxPeers: 25, + NAT: nat.Any(), + }, +} + // DefaultDataDir is the default data directory to use for the databases and other // persistence requirements. func DefaultDataDir() string {