mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +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/dashboard"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/internal/debug"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
||||
|
|
@ -72,7 +73,7 @@ var tomlSettings = toml.Config{
|
|||
}
|
||||
|
||||
type ethstatsConfig struct {
|
||||
URL string `toml:",omitempty"`
|
||||
URL string
|
||||
}
|
||||
|
||||
type account struct {
|
||||
|
|
@ -94,6 +95,8 @@ type XDCConfig struct {
|
|||
Account account
|
||||
StakeEnable bool
|
||||
Bootnodes Bootnodes
|
||||
Verbosity int
|
||||
NAT string
|
||||
}
|
||||
|
||||
func loadConfig(file string, cfg *XDCConfig) error {
|
||||
|
|
@ -123,10 +126,13 @@ func defaultNodeConfig() node.Config {
|
|||
func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
||||
// Load defaults.
|
||||
cfg := XDCConfig{
|
||||
Eth: eth.DefaultConfig,
|
||||
Shh: whisper.DefaultConfig,
|
||||
Node: defaultNodeConfig(),
|
||||
Dashboard: dashboard.DefaultConfig,
|
||||
Eth: eth.DefaultConfig,
|
||||
Shh: whisper.DefaultConfig,
|
||||
Node: defaultNodeConfig(),
|
||||
Dashboard: dashboard.DefaultConfig,
|
||||
StakeEnable: true,
|
||||
Verbosity: 0,
|
||||
NAT: "",
|
||||
}
|
||||
// Load config file.
|
||||
if file := ctx.GlobalString(configFileFlag.Name); file != "" {
|
||||
|
|
@ -134,6 +140,16 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
|||
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
|
||||
passwords := []string{}
|
||||
|
|
@ -149,7 +165,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
|||
}
|
||||
cfg.Account.Passwords = passwords
|
||||
|
||||
// Apply flags.
|
||||
// Apply flags.
|
||||
utils.SetNodeConfig(ctx, &cfg.Node)
|
||||
stack, err := node.New(&cfg.Node)
|
||||
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]
|
||||
NetworkId = 89 # flag --networkid
|
||||
SyncMode = "full" # flag --syncmode
|
||||
GasPrice = 1 # flag --gasprice
|
||||
NetworkId = 89 # flag --networkid
|
||||
SyncMode = "full" # flag --syncmode
|
||||
GasPrice = 1 # flag --gasprice
|
||||
|
||||
[Shh]
|
||||
|
||||
[Node]
|
||||
DataDir = "node1/" # flag --datadir
|
||||
HTTPHost = "localhost" # flag --rpcaddr
|
||||
HTTPPort = 8501 # flag --rpcport
|
||||
HTTPModules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi
|
||||
DataDir = "node1/" # flag --datadir
|
||||
HTTPPort = 8501 # flag --rpcport
|
||||
HTTPHost = "localhost" # flags --rpcaddr & --rpc
|
||||
# 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]
|
||||
ListenAddr = ":30311" # flag --port
|
||||
BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"]
|
||||
# flag --bootnodes
|
||||
ListenAddr = ":30311" # flag --port
|
||||
|
||||
|
||||
BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] # flag --bootnodes
|
||||
|
||||
[Ethstats]
|
||||
URL = "" # flag --ethstats
|
||||
|
||||
[Dashboard]
|
||||
|
||||
[Account]
|
||||
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]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
verbosityFlag = cli.IntFlag{
|
||||
VerbosityFlag = cli.IntFlag{
|
||||
Name: "verbosity",
|
||||
Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail",
|
||||
Value: 3,
|
||||
|
|
@ -87,7 +87,7 @@ var (
|
|||
|
||||
// Flags holds all command-line flags required for debugging.
|
||||
var Flags = []cli.Flag{
|
||||
verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
|
||||
VerbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
|
||||
pprofFlag, pprofAddrFlag, pprofPortFlag,
|
||||
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ func init() {
|
|||
func Setup(ctx *cli.Context) error {
|
||||
// logging
|
||||
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.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name))
|
||||
log.Root().SetHandler(glogger)
|
||||
|
|
@ -149,4 +149,4 @@ func Setup(ctx *cli.Context) error {
|
|||
func Exit() {
|
||||
Handler.StopCPUProfile()
|
||||
Handler.StopGoTrace()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue