mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
node: add DefaultConfig, use it for geth
This commit is contained in:
parent
85b38613b2
commit
087d06f836
2 changed files with 28 additions and 11 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue