diff options
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r-- | cmd/utils/flags.go | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 689202c69..513557a03 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -49,6 +49,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/influxdb" + "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discv5" @@ -375,27 +376,27 @@ var ( MinerGasTargetFlag = cli.Uint64Flag{ Name: "miner.gastarget", Usage: "Target gas floor for mined blocks", - Value: eth.DefaultConfig.MinerGasFloor, + Value: eth.DefaultConfig.Miner.GasFloor, } MinerLegacyGasTargetFlag = cli.Uint64Flag{ Name: "targetgaslimit", Usage: "Target gas floor for mined blocks (deprecated, use --miner.gastarget)", - Value: eth.DefaultConfig.MinerGasFloor, + Value: eth.DefaultConfig.Miner.GasFloor, } MinerGasLimitFlag = cli.Uint64Flag{ Name: "miner.gaslimit", Usage: "Target gas ceiling for mined blocks", - Value: eth.DefaultConfig.MinerGasCeil, + Value: eth.DefaultConfig.Miner.GasCeil, } MinerGasPriceFlag = BigFlag{ Name: "miner.gasprice", Usage: "Minimum gas price for mining a transaction", - Value: eth.DefaultConfig.MinerGasPrice, + Value: eth.DefaultConfig.Miner.GasPrice, } MinerLegacyGasPriceFlag = BigFlag{ Name: "gasprice", Usage: "Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)", - Value: eth.DefaultConfig.MinerGasPrice, + Value: eth.DefaultConfig.Miner.GasPrice, } MinerEtherbaseFlag = cli.StringFlag{ Name: "miner.etherbase", @@ -418,7 +419,7 @@ var ( MinerRecommitIntervalFlag = cli.DurationFlag{ Name: "miner.recommit", Usage: "Time interval to recreate the block being mined", - Value: eth.DefaultConfig.MinerRecommit, + Value: eth.DefaultConfig.Miner.Recommit, } MinerNoVerfiyFlag = cli.BoolFlag{ Name: "miner.noverify", @@ -1023,7 +1024,7 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) { if err != nil { Fatalf("Invalid miner etherbase: %v", err) } - cfg.Etherbase = account.Address + cfg.Miner.Etherbase = account.Address } else { Fatalf("No etherbase configured") } @@ -1231,6 +1232,39 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) { } } +func setMiner(ctx *cli.Context, cfg *miner.Config) { + if ctx.GlobalIsSet(MinerNotifyFlag.Name) { + cfg.Notify = strings.Split(ctx.GlobalString(MinerNotifyFlag.Name), ",") + } + if ctx.GlobalIsSet(MinerLegacyExtraDataFlag.Name) { + cfg.ExtraData = []byte(ctx.GlobalString(MinerLegacyExtraDataFlag.Name)) + } + if ctx.GlobalIsSet(MinerExtraDataFlag.Name) { + cfg.ExtraData = []byte(ctx.GlobalString(MinerExtraDataFlag.Name)) + } + if ctx.GlobalIsSet(MinerLegacyGasTargetFlag.Name) { + cfg.GasFloor = ctx.GlobalUint64(MinerLegacyGasTargetFlag.Name) + } + if ctx.GlobalIsSet(MinerGasTargetFlag.Name) { + cfg.GasFloor = ctx.GlobalUint64(MinerGasTargetFlag.Name) + } + if ctx.GlobalIsSet(MinerGasLimitFlag.Name) { + cfg.GasCeil = ctx.GlobalUint64(MinerGasLimitFlag.Name) + } + if ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { + cfg.GasPrice = GlobalBig(ctx, MinerLegacyGasPriceFlag.Name) + } + if ctx.GlobalIsSet(MinerGasPriceFlag.Name) { + cfg.GasPrice = GlobalBig(ctx, MinerGasPriceFlag.Name) + } + if ctx.GlobalIsSet(MinerRecommitIntervalFlag.Name) { + cfg.Recommit = ctx.Duration(MinerRecommitIntervalFlag.Name) + } + if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) { + cfg.Noverify = ctx.Bool(MinerNoVerfiyFlag.Name) + } +} + func setWhitelist(ctx *cli.Context, cfg *eth.Config) { whitelist := ctx.GlobalString(WhitelistFlag.Name) if whitelist == "" { @@ -1323,6 +1357,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { setGPO(ctx, &cfg.GPO) setTxPool(ctx, &cfg.TxPool) setEthash(ctx, cfg) + setMiner(ctx, &cfg.Miner) setWhitelist(ctx, cfg) if ctx.GlobalIsSet(SyncModeFlag.Name) { @@ -1359,39 +1394,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) { cfg.TrieDirtyCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 } - if ctx.GlobalIsSet(MinerNotifyFlag.Name) { - cfg.MinerNotify = strings.Split(ctx.GlobalString(MinerNotifyFlag.Name), ",") - } if ctx.GlobalIsSet(DocRootFlag.Name) { cfg.DocRoot = ctx.GlobalString(DocRootFlag.Name) } - if ctx.GlobalIsSet(MinerLegacyExtraDataFlag.Name) { - cfg.MinerExtraData = []byte(ctx.GlobalString(MinerLegacyExtraDataFlag.Name)) - } - if ctx.GlobalIsSet(MinerExtraDataFlag.Name) { - cfg.MinerExtraData = []byte(ctx.GlobalString(MinerExtraDataFlag.Name)) - } - if ctx.GlobalIsSet(MinerLegacyGasTargetFlag.Name) { - cfg.MinerGasFloor = ctx.GlobalUint64(MinerLegacyGasTargetFlag.Name) - } - if ctx.GlobalIsSet(MinerGasTargetFlag.Name) { - cfg.MinerGasFloor = ctx.GlobalUint64(MinerGasTargetFlag.Name) - } - if ctx.GlobalIsSet(MinerGasLimitFlag.Name) { - cfg.MinerGasCeil = ctx.GlobalUint64(MinerGasLimitFlag.Name) - } - if ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { - cfg.MinerGasPrice = GlobalBig(ctx, MinerLegacyGasPriceFlag.Name) - } - if ctx.GlobalIsSet(MinerGasPriceFlag.Name) { - cfg.MinerGasPrice = GlobalBig(ctx, MinerGasPriceFlag.Name) - } - if ctx.GlobalIsSet(MinerRecommitIntervalFlag.Name) { - cfg.MinerRecommit = ctx.Duration(MinerRecommitIntervalFlag.Name) - } - if ctx.GlobalIsSet(MinerNoVerfiyFlag.Name) { - cfg.MinerNoverify = ctx.Bool(MinerNoVerfiyFlag.Name) - } if ctx.GlobalIsSet(VMEnableDebugFlag.Name) { // TODO(fjl): force-enable this in --dev mode cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name) @@ -1449,7 +1454,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address) if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) { - cfg.MinerGasPrice = big.NewInt(1) + cfg.Miner.GasPrice = big.NewInt(1) } } } |