From d9437678a6bc6873092350a134da7733a5065864 Mon Sep 17 00:00:00 2001 From: renaynay <41963722+renaynay@users.noreply.github.com> Date: Tue, 21 Apr 2020 15:23:12 +0200 Subject: [PATCH] fixed circular import --- cmd/geth/main.go | 14 ++++-------- cmd/geth/usage.go | 9 ++------ cmd/utils/flags_legacy.go | 24 -------------------- internal/debug/flags.go | 47 ++++++++++++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 51 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index d4b9774515..1eb8a9e85a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -20,7 +20,6 @@ package main import ( "fmt" "math" - "math/big" "os" "runtime" godebug "runtime/debug" @@ -459,24 +458,19 @@ func startNode(ctx *cli.Context, stack *node.Node) { utils.Fatalf("Ethereum service not running: %v", err) } // Set the gas price to the limits from the CLI and start mining - var gasprice *big.Int - if ctx.IsSet(utils.LegacyMinerGasPriceFlag.Name) { + gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) + if ctx.IsSet(utils.LegacyMinerGasPriceFlag.Name) && !ctx.IsSet(utils.MinerGasPriceFlag.Name) { gasprice = utils.GlobalBig(ctx, utils.LegacyMinerGasPriceFlag.Name) log.Warn("The flag --gasprice is deprecated and will be removed in the future, please use --miner.gasprice") } - gasprice = utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) ethereum.TxPool().SetGasPrice(gasprice) - var threads int - if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) { + threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name) + if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) && !ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) { threads = ctx.GlobalInt(utils.LegacyMinerThreadsFlag.Name) log.Warn("The flag --minerthreads is deprecated and will be removed in the future, please use --miner.threads") } - threads = ctx.GlobalInt(utils.MinerThreadsFlag.Name) - if ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) { - threads = ctx.GlobalInt(utils.MinerThreadsFlag.Name) - } if err := ethereum.StartMining(threads); err != nil { utils.Fatalf("Failed to start mining: %v", err) } diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 30f65e1fb7..5b8a45f4c2 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -244,7 +244,7 @@ var AppHelpFlagGroups = []flagGroup{ }, { Name: "ALIASED (deprecated)", - Flags: []cli.Flag{ + Flags: append([]cli.Flag{ utils.LegacyRPCEnabledFlag, utils.LegacyRPCListenAddrFlag, utils.LegacyRPCPortFlag, @@ -257,12 +257,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.LegacyWSApiFlag, utils.LegacyGpoBlocksFlag, utils.LegacyGpoPercentileFlag, - utils.LegacyPprofAddrFlag, - utils.LegacyPprofPortFlag, - utils.LegacyMemprofilerateFlag, - utils.LegacyBlockprofilerateFlag, - utils.LegacyCpuprofileFlag, - }, + }, debug.DeprecatedFlags...), }, { Name: "MISC", diff --git a/cmd/utils/flags_legacy.go b/cmd/utils/flags_legacy.go index 39170cfba0..eccb0471e4 100644 --- a/cmd/utils/flags_legacy.go +++ b/cmd/utils/flags_legacy.go @@ -21,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/node" "gopkg.in/urfave/cli.v1" - "runtime" "strings" ) @@ -139,29 +138,6 @@ var ( Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices (deprecated, use --gpo.percentile)", Value: eth.DefaultConfig.GPO.Percentile, } - LegacyPprofPortFlag = cli.IntFlag{ - Name: "pprofport", - Usage: "pprof HTTP server listening port (deprecated, use --pprof.port)", - Value: 6060, - } - LegacyPprofAddrFlag = cli.StringFlag{ - Name: "pprofaddr", - Usage: "pprof HTTP server listening interface (deprecated, use --pprof.addr)", - Value: "127.0.0.1", - } - LegacyMemprofilerateFlag = cli.IntFlag{ - Name: "memprofilerate", - Usage: "Turn on memory profiling with the given rate (deprecated, use --pprof.memprofilerate)", - Value: runtime.MemProfileRate, - } - LegacyBlockprofilerateFlag = cli.IntFlag{ - Name: "blockprofilerate", - Usage: "Turn on block profiling with the given rate (deprecated, use --pprof.blockprofilerate)", - } - LegacyCpuprofileFlag = cli.StringFlag{ - Name: "cpuprofile", - Usage: "Write CPU profile to the given file (deprecated, use --pprof.cpuprofile)", - } ) func showDeprecated(c *cli.Context) { diff --git a/internal/debug/flags.go b/internal/debug/flags.go index b350d0ca06..bffd5acb24 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -18,7 +18,6 @@ package debug import ( "fmt" - "github.com/ethereum/go-ethereum/cmd/utils" "io" "net/http" _ "net/http/pprof" @@ -87,6 +86,29 @@ var ( Name: "trace", Usage: "Write execution trace to the given file", } + legacyPprofPortFlag = cli.IntFlag{ + Name: "pprofport", + Usage: "pprof HTTP server listening port (deprecated, use --pprof.port)", + Value: 6060, + } + legacyPprofAddrFlag = cli.StringFlag{ + Name: "pprofaddr", + Usage: "pprof HTTP server listening interface (deprecated, use --pprof.addr)", + Value: "127.0.0.1", + } + legacyMemprofilerateFlag = cli.IntFlag{ + Name: "memprofilerate", + Usage: "Turn on memory profiling with the given rate (deprecated, use --pprof.memprofilerate)", + Value: runtime.MemProfileRate, + } + legacyBlockprofilerateFlag = cli.IntFlag{ + Name: "blockprofilerate", + Usage: "Turn on block profiling with the given rate (deprecated, use --pprof.blockprofilerate)", + } + legacyCpuprofileFlag = cli.StringFlag{ + Name: "cpuprofile", + Usage: "Write CPU profile to the given file (deprecated, use --pprof.cpuprofile)", + } ) // Flags holds all command-line flags required for debugging. @@ -96,6 +118,11 @@ var Flags = []cli.Flag{ blockprofilerateFlag, cpuprofileFlag, traceFlag, } +var DeprecatedFlags = []cli.Flag{ + legacyPprofPortFlag, legacyPprofAddrFlag, legacyMemprofilerateFlag, + legacyBlockprofilerateFlag, legacyCpuprofileFlag, +} + var ( ostream log.Handler glogger *log.GlogHandler @@ -122,14 +149,14 @@ func Setup(ctx *cli.Context) error { log.Root().SetHandler(glogger) // profiling, tracing - if ctx.GlobalIsSet(utils.LegacyMemprofilerateFlag.Name) { - runtime.MemProfileRate = ctx.GlobalInt(utils.LegacyMemprofilerateFlag.Name) + if ctx.GlobalIsSet(legacyMemprofilerateFlag.Name) { + runtime.MemProfileRate = ctx.GlobalInt(legacyMemprofilerateFlag.Name) log.Warn("The flag --memprofilerate is deprecated and will be removed in the future, please use --pprof.memprofilerate") } runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) - if ctx.GlobalIsSet(utils.LegacyBlockprofilerateFlag.Name) { - Handler.SetBlockProfileRate(ctx.GlobalInt(utils.LegacyBlockprofilerateFlag.Name)) + if ctx.GlobalIsSet(legacyBlockprofilerateFlag.Name) { + Handler.SetBlockProfileRate(ctx.GlobalInt(legacyBlockprofilerateFlag.Name)) log.Warn("The flag --blockprofilerate is deprecated and will be removed in the future, please use --pprof.blockprofilerate") } Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name)) @@ -145,7 +172,7 @@ func Setup(ctx *cli.Context) error { return err } } - if cpuFile := ctx.GlobalString(utils.LegacyCpuprofileFlag.Name); cpuFile != "" { + if cpuFile := ctx.GlobalString(legacyCpuprofileFlag.Name); cpuFile != "" { log.Warn("The flag --cpuprofile is deprecated and will be removed in the future, please use --pprof.cpuprofile") if err := Handler.StartCPUProfile(cpuFile); err != nil { return err @@ -155,14 +182,14 @@ func Setup(ctx *cli.Context) error { // pprof server if ctx.GlobalBool(pprofFlag.Name) { listenHost := ctx.GlobalString(pprofAddrFlag.Name) - if ctx.GlobalIsSet(utils.LegacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) { - listenHost = ctx.GlobalString(utils.LegacyPprofAddrFlag.Name) + if ctx.GlobalIsSet(legacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) { + listenHost = ctx.GlobalString(legacyPprofAddrFlag.Name) log.Warn("The flag --pprofaddr is deprecated and will be removed in the future, please use --pprof.addr") } port := ctx.GlobalInt(pprofPortFlag.Name) - if ctx.GlobalIsSet(utils.LegacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) { - port = ctx.GlobalInt(utils.LegacyPprofPortFlag.Name) + if ctx.GlobalIsSet(legacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) { + port = ctx.GlobalInt(legacyPprofPortFlag.Name) log.Warn("The flag --pprofport is deprecated and will be removed in the future, please use --pprof.port") }