Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions cmd/opera/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/naoina/toml"
"github.com/syndtr/goleveldb/leveldb/opt"
"gopkg.in/urfave/cli.v1"
Expand Down Expand Up @@ -486,7 +485,7 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
// Defaults (low priority)
cacheRatio := cacheScaler(ctx)
cfg := config{
Node: defaultNodeConfig(),
Node: DefaultNodeConfig(),
Opera: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
Expand Down Expand Up @@ -556,17 +555,6 @@ func makeAllConfigs(ctx *cli.Context) *config {
return cfg
}

func defaultNodeConfig() node.Config {
cfg := NodeDefaultConfig
cfg.Name = clientIdentifier
cfg.Version = params.VersionWithCommit(gitCommit, gitDate)
cfg.HTTPModules = append(cfg.HTTPModules, "eth", "ftm", "dag", "abft", "web3")
cfg.WSModules = append(cfg.WSModules, "eth", "ftm", "dag", "abft", "web3")
cfg.IPCPath = "opera.ipc"
cfg.DataDir = DefaultDataDir()
return cfg
}

// dumpConfig is the dumpconfig command.
func dumpConfig(ctx *cli.Context) error {
cfg := makeAllConfigs(ctx)
Expand Down
2 changes: 1 addition & 1 deletion cmd/opera/launcher/config_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestConfigFile(t *testing.T) {
}

src := config{
Node: defaultNodeConfig(),
Node: DefaultNodeConfig(),
Opera: gossip.DefaultConfig(cacheRatio),
Emitter: emitter.DefaultConfig(),
TxPool: evmcore.DefaultTxPoolConfig,
Expand Down
40 changes: 23 additions & 17 deletions cmd/opera/launcher/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
)

Expand All @@ -27,23 +28,28 @@ func overrideFlags() {
utils.WSPortFlag.Value = DefaultWSPort
}

// NodeDefaultConfig contains reasonable default settings.
var NodeDefaultConfig = node.Config{
DataDir: DefaultDataDir(),
HTTPPort: DefaultHTTPPort,
HTTPModules: []string{},
HTTPVirtualHosts: []string{"localhost"},
HTTPTimeouts: rpc.DefaultHTTPTimeouts,
WSPort: DefaultWSPort,
WSModules: []string{},
GraphQLVirtualHosts: []string{"localhost"},
P2P: p2p.Config{
NoDiscovery: false, // enable discovery v4 by default
DiscoveryV5: true, // enable discovery v5 by default
ListenAddr: fmt.Sprintf(":%d", DefaultP2PPort),
MaxPeers: 50,
NAT: nat.Any(),
},
// DefaultNodeConfig creates reasonable default configuration settings
func DefaultNodeConfig() node.Config {
return node.Config{
DataDir: DefaultDataDir(),
HTTPPort: DefaultHTTPPort,
HTTPTimeouts: rpc.DefaultHTTPTimeouts,
HTTPVirtualHosts: []string{"localhost"},
HTTPModules: []string{"eth", "ftm", "dag", "abft", "web3"},
WSModules: []string{"eth", "ftm", "dag", "abft", "web3"},
WSPort: DefaultWSPort,
GraphQLVirtualHosts: []string{"localhost"},
P2P: p2p.Config{
NoDiscovery: false, // enable discovery v4 by default
DiscoveryV5: true, // enable discovery v5 by default
ListenAddr: fmt.Sprintf(":%d", DefaultP2PPort),
MaxPeers: 50,
NAT: nat.Any(),
},
Name: clientIdentifier,
Version: params.VersionWithCommit(gitCommit, gitDate),
IPCPath: "opera.ipc",
}
}

// DefaultDataDir is the default data directory to use for the databases and other
Expand Down
2 changes: 1 addition & 1 deletion cmd/opera/launcher/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type testcli struct {
}

func (tt *testcli) readConfig() {
cfg := defaultNodeConfig()
cfg := DefaultNodeConfig()
cfg.DataDir = tt.Datadir
addr := common.Address{} // TODO: addr = emitter coinbase
tt.Coinbase = strings.ToLower(addr.String())
Expand Down