mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
add some config to toml file
This commit is contained in:
parent
7e7bc37c20
commit
b969dc7790
3 changed files with 57 additions and 22 deletions
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/dashboard"
|
"github.com/ethereum/go-ethereum/dashboard"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/debug"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
||||||
|
|
@ -72,7 +73,7 @@ var tomlSettings = toml.Config{
|
||||||
}
|
}
|
||||||
|
|
||||||
type ethstatsConfig struct {
|
type ethstatsConfig struct {
|
||||||
URL string `toml:",omitempty"`
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type account struct {
|
type account struct {
|
||||||
|
|
@ -94,6 +95,8 @@ type XDCConfig struct {
|
||||||
Account account
|
Account account
|
||||||
StakeEnable bool
|
StakeEnable bool
|
||||||
Bootnodes Bootnodes
|
Bootnodes Bootnodes
|
||||||
|
Verbosity int
|
||||||
|
NAT string
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(file string, cfg *XDCConfig) error {
|
func loadConfig(file string, cfg *XDCConfig) error {
|
||||||
|
|
@ -123,10 +126,13 @@ func defaultNodeConfig() node.Config {
|
||||||
func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
||||||
// Load defaults.
|
// Load defaults.
|
||||||
cfg := XDCConfig{
|
cfg := XDCConfig{
|
||||||
Eth: eth.DefaultConfig,
|
Eth: eth.DefaultConfig,
|
||||||
Shh: whisper.DefaultConfig,
|
Shh: whisper.DefaultConfig,
|
||||||
Node: defaultNodeConfig(),
|
Node: defaultNodeConfig(),
|
||||||
Dashboard: dashboard.DefaultConfig,
|
Dashboard: dashboard.DefaultConfig,
|
||||||
|
StakeEnable: true,
|
||||||
|
Verbosity: 0,
|
||||||
|
NAT: "",
|
||||||
}
|
}
|
||||||
// Load config file.
|
// Load config file.
|
||||||
if file := ctx.GlobalString(configFileFlag.Name); file != "" {
|
if file := ctx.GlobalString(configFileFlag.Name); file != "" {
|
||||||
|
|
@ -134,6 +140,16 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ctx.GlobalIsSet(utils.StakingEnabledFlag.Name) {
|
||||||
|
cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name)
|
||||||
|
}
|
||||||
|
if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
|
||||||
|
ctx.Set(debug.VerbosityFlag.Name, string(cfg.Verbosity))
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ctx.GlobalIsSet(utils.NATFlag.Name) && cfg.NAT != "" {
|
||||||
|
ctx.Set(utils.NATFlag.Name, cfg.NAT)
|
||||||
|
}
|
||||||
|
|
||||||
// read passwords from enviroment
|
// read passwords from enviroment
|
||||||
passwords := []string{}
|
passwords := []string{}
|
||||||
|
|
@ -149,7 +165,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
||||||
}
|
}
|
||||||
cfg.Account.Passwords = passwords
|
cfg.Account.Passwords = passwords
|
||||||
|
|
||||||
// Apply flags.
|
// Apply flags.
|
||||||
utils.SetNodeConfig(ctx, &cfg.Node)
|
utils.SetNodeConfig(ctx, &cfg.Node)
|
||||||
stack, err := node.New(&cfg.Node)
|
stack, err := node.New(&cfg.Node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
43
cmd/XDC/testdata/config.toml
vendored
43
cmd/XDC/testdata/config.toml
vendored
|
|
@ -1,26 +1,45 @@
|
||||||
StakeEnable = true # flag --miner ( true : enable staker , false : disable )
|
StakeEnable = true # flag --miner ( true : enable staker , false : disable )
|
||||||
|
Verbosity = 0 # flag --verbosity (0=Crit 1=Error 2=Warn 3=Info 4=Debug 5=Trace)
|
||||||
|
NAT = "" # flag --nat
|
||||||
|
|
||||||
[Eth]
|
[Eth]
|
||||||
NetworkId = 89 # flag --networkid
|
NetworkId = 89 # flag --networkid
|
||||||
SyncMode = "full" # flag --syncmode
|
SyncMode = "full" # flag --syncmode
|
||||||
GasPrice = 1 # flag --gasprice
|
GasPrice = 1 # flag --gasprice
|
||||||
|
|
||||||
[Shh]
|
[Shh]
|
||||||
|
|
||||||
[Node]
|
[Node]
|
||||||
DataDir = "node1/" # flag --datadir
|
DataDir = "node1/" # flag --datadir
|
||||||
HTTPHost = "localhost" # flag --rpcaddr
|
HTTPPort = 8501 # flag --rpcport
|
||||||
HTTPPort = 8501 # flag --rpcport
|
HTTPHost = "localhost" # flags --rpcaddr & --rpc
|
||||||
HTTPModules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi
|
# in 3 cases :
|
||||||
|
# HTTPHost is "" == --rpc & --rpcaddr is not set
|
||||||
|
# HTTPHost is "localhost" or "127.0.0.1" == only set --rpc
|
||||||
|
# HTTPHost is other IP (ex : 192.168.1.1) = set 2 flags --rpc & --rpcaddr
|
||||||
|
WSHost = "localhost" # flags --wsaddr & --ws . same option HTTPHost
|
||||||
|
WSPort = 8546 # flag --wsport
|
||||||
|
WSModules = ["eth","ssh"] #flag --wsapi
|
||||||
|
|
||||||
|
|
||||||
|
HTTPModules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi
|
||||||
|
KeyStoreDir = "" # flag --keystore
|
||||||
|
UserIdent = "" # flag --identity
|
||||||
|
|
||||||
[Node.P2P]
|
[Node.P2P]
|
||||||
ListenAddr = ":30311" # flag --port
|
ListenAddr = ":30311" # flag --port
|
||||||
BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"]
|
|
||||||
# flag --bootnodes
|
|
||||||
|
BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] # flag --bootnodes
|
||||||
|
|
||||||
[Ethstats]
|
[Ethstats]
|
||||||
|
URL = "" # flag --ethstats
|
||||||
|
|
||||||
[Dashboard]
|
[Dashboard]
|
||||||
|
|
||||||
[Account]
|
[Account]
|
||||||
Unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock
|
Unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock
|
||||||
Passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789
|
Passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789
|
||||||
|
|
||||||
|
|
||||||
[Bootnodes]
|
[Bootnodes]
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
verbosityFlag = cli.IntFlag{
|
VerbosityFlag = cli.IntFlag{
|
||||||
Name: "verbosity",
|
Name: "verbosity",
|
||||||
Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail",
|
Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail",
|
||||||
Value: 3,
|
Value: 3,
|
||||||
|
|
@ -87,7 +87,7 @@ var (
|
||||||
|
|
||||||
// Flags holds all command-line flags required for debugging.
|
// Flags holds all command-line flags required for debugging.
|
||||||
var Flags = []cli.Flag{
|
var Flags = []cli.Flag{
|
||||||
verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
|
VerbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
|
||||||
pprofFlag, pprofAddrFlag, pprofPortFlag,
|
pprofFlag, pprofAddrFlag, pprofPortFlag,
|
||||||
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
|
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +108,7 @@ func init() {
|
||||||
func Setup(ctx *cli.Context) error {
|
func Setup(ctx *cli.Context) error {
|
||||||
// logging
|
// logging
|
||||||
log.PrintOrigins(ctx.GlobalBool(debugFlag.Name))
|
log.PrintOrigins(ctx.GlobalBool(debugFlag.Name))
|
||||||
glogger.Verbosity(log.Lvl(ctx.GlobalInt(verbosityFlag.Name)))
|
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
|
||||||
glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name))
|
glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name))
|
||||||
glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name))
|
glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name))
|
||||||
log.Root().SetHandler(glogger)
|
log.Root().SetHandler(glogger)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue