From 953e13b21b0aae335ef655a1907a8883f1ba7be2 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Tue, 25 Sep 2018 18:55:00 +0800 Subject: Use dex.Config instead of eth.Config --- cmd/geth/config.go | 19 ++++++++----------- cmd/utils/flags.go | 50 +++++++------------------------------------------- 2 files changed, 15 insertions(+), 54 deletions(-) (limited to 'cmd') diff --git a/cmd/geth/config.go b/cmd/geth/config.go index f1e281196..6e37fd397 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -20,7 +20,6 @@ import ( "bufio" "errors" "fmt" - "math/big" "os" "reflect" "unicode" @@ -29,7 +28,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/dex" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" @@ -75,7 +74,7 @@ type ethstatsConfig struct { } type gethConfig struct { - Eth eth.Config + Dex dex.Config Shh whisper.Config Node node.Config Ethstats ethstatsConfig @@ -110,7 +109,7 @@ func defaultNodeConfig() node.Config { func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { // Load defaults. cfg := gethConfig{ - Eth: eth.DefaultConfig, + Dex: dex.DefaultConfig, Shh: whisper.DefaultConfig, Node: defaultNodeConfig(), Dashboard: dashboard.DefaultConfig, @@ -129,7 +128,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { if err != nil { utils.Fatalf("Failed to create the protocol stack: %v", err) } - utils.SetEthConfig(ctx, stack, &cfg.Eth) + utils.SetDexConfig(ctx, stack, &cfg.Dex) if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) { cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name) } @@ -152,10 +151,8 @@ func enableWhisper(ctx *cli.Context) bool { func makeFullNode(ctx *cli.Context) *node.Node { stack, cfg := makeConfigNode(ctx) - if ctx.GlobalIsSet(utils.ConstantinopleOverrideFlag.Name) { - cfg.Eth.ConstantinopleOverride = new(big.Int).SetUint64(ctx.GlobalUint64(utils.ConstantinopleOverrideFlag.Name)) - } - utils.RegisterEthService(stack, &cfg.Eth) + + utils.RegisterDexService(stack, &cfg.Dex) if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) { utils.RegisterDashboardService(stack, &cfg.Dashboard, gitCommit) @@ -188,8 +185,8 @@ func dumpConfig(ctx *cli.Context) error { _, cfg := makeConfigNode(ctx) comment := "" - if cfg.Eth.Genesis != nil { - cfg.Eth.Genesis = nil + if cfg.Dex.Genesis != nil { + cfg.Dex.Genesis = nil comment += "# Note: this config doesn't contain the genesis block.\n\n" } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b75a67ca5..c9f81b400 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1175,18 +1175,15 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) { } } -// SetEthConfig applies eth-related command line flags to the config. -func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { +// SetDexConfig applies eth-related command line flags to the config. +func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { // Avoid conflicting network flags checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, GoerliFlag) checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - setEtherbase(ctx, ks, cfg) setGPO(ctx, &cfg.GPO) setTxPool(ctx, &cfg.TxPool) - setEthash(ctx, cfg) - setWhitelist(ctx, cfg) if ctx.GlobalIsSet(SyncModeFlag.Name) { cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode) @@ -1216,39 +1213,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) @@ -1305,9 +1272,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { log.Info("Using developer account", "address", developer.Address) 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) - } } // TODO(fjl): move trie cache generations into config if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 { @@ -1322,13 +1286,13 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) { cfg.Refresh = ctx.GlobalDuration(DashboardRefreshFlag.Name) } -// RegisterEthService adds an Ethereum client to the stack. -func RegisterEthService(stack *node.Node, cfg *eth.Config) { +// RegisterDexService adds an Dexon client to the stack. +func RegisterDexService(stack *node.Node, cfg *dex.Config) { var err error if cfg.SyncMode == downloader.LightSync { - err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return les.New(ctx, cfg) - }) + //err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + // return les.New(ctx, cfg) + //}) } else { err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { fullNode, err := dex.New(ctx, cfg) -- cgit v1.2.3