fixed circular import

This commit is contained in:
renaynay 2020-04-21 15:23:12 +02:00
parent 2f4386a0da
commit d9437678a6
No known key found for this signature in database
GPG key ID: 6557F5413D663EDB
4 changed files with 43 additions and 51 deletions

View file

@ -20,7 +20,6 @@ package main
import ( import (
"fmt" "fmt"
"math" "math"
"math/big"
"os" "os"
"runtime" "runtime"
godebug "runtime/debug" godebug "runtime/debug"
@ -459,24 +458,19 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.Fatalf("Ethereum service not running: %v", err) utils.Fatalf("Ethereum service not running: %v", err)
} }
// Set the gas price to the limits from the CLI and start mining // Set the gas price to the limits from the CLI and start mining
var gasprice *big.Int gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
if ctx.IsSet(utils.LegacyMinerGasPriceFlag.Name) { if ctx.IsSet(utils.LegacyMinerGasPriceFlag.Name) && !ctx.IsSet(utils.MinerGasPriceFlag.Name) {
gasprice = utils.GlobalBig(ctx, utils.LegacyMinerGasPriceFlag.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") 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) ethereum.TxPool().SetGasPrice(gasprice)
var threads int threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name)
if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) { if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) && !ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) {
threads = ctx.GlobalInt(utils.LegacyMinerThreadsFlag.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") 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 { if err := ethereum.StartMining(threads); err != nil {
utils.Fatalf("Failed to start mining: %v", err) utils.Fatalf("Failed to start mining: %v", err)
} }

View file

@ -244,7 +244,7 @@ var AppHelpFlagGroups = []flagGroup{
}, },
{ {
Name: "ALIASED (deprecated)", Name: "ALIASED (deprecated)",
Flags: []cli.Flag{ Flags: append([]cli.Flag{
utils.LegacyRPCEnabledFlag, utils.LegacyRPCEnabledFlag,
utils.LegacyRPCListenAddrFlag, utils.LegacyRPCListenAddrFlag,
utils.LegacyRPCPortFlag, utils.LegacyRPCPortFlag,
@ -257,12 +257,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.LegacyWSApiFlag, utils.LegacyWSApiFlag,
utils.LegacyGpoBlocksFlag, utils.LegacyGpoBlocksFlag,
utils.LegacyGpoPercentileFlag, utils.LegacyGpoPercentileFlag,
utils.LegacyPprofAddrFlag, }, debug.DeprecatedFlags...),
utils.LegacyPprofPortFlag,
utils.LegacyMemprofilerateFlag,
utils.LegacyBlockprofilerateFlag,
utils.LegacyCpuprofileFlag,
},
}, },
{ {
Name: "MISC", Name: "MISC",

View file

@ -21,7 +21,6 @@ import (
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
"runtime"
"strings" "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)", 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, 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) { func showDeprecated(c *cli.Context) {

View file

@ -18,7 +18,6 @@ package debug
import ( import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/cmd/utils"
"io" "io"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
@ -87,6 +86,29 @@ var (
Name: "trace", Name: "trace",
Usage: "Write execution trace to the given file", 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. // Flags holds all command-line flags required for debugging.
@ -96,6 +118,11 @@ var Flags = []cli.Flag{
blockprofilerateFlag, cpuprofileFlag, traceFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
} }
var DeprecatedFlags = []cli.Flag{
legacyPprofPortFlag, legacyPprofAddrFlag, legacyMemprofilerateFlag,
legacyBlockprofilerateFlag, legacyCpuprofileFlag,
}
var ( var (
ostream log.Handler ostream log.Handler
glogger *log.GlogHandler glogger *log.GlogHandler
@ -122,14 +149,14 @@ func Setup(ctx *cli.Context) error {
log.Root().SetHandler(glogger) log.Root().SetHandler(glogger)
// profiling, tracing // profiling, tracing
if ctx.GlobalIsSet(utils.LegacyMemprofilerateFlag.Name) { if ctx.GlobalIsSet(legacyMemprofilerateFlag.Name) {
runtime.MemProfileRate = ctx.GlobalInt(utils.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") log.Warn("The flag --memprofilerate is deprecated and will be removed in the future, please use --pprof.memprofilerate")
} }
runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)
if ctx.GlobalIsSet(utils.LegacyBlockprofilerateFlag.Name) { if ctx.GlobalIsSet(legacyBlockprofilerateFlag.Name) {
Handler.SetBlockProfileRate(ctx.GlobalInt(utils.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") log.Warn("The flag --blockprofilerate is deprecated and will be removed in the future, please use --pprof.blockprofilerate")
} }
Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name)) Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name))
@ -145,7 +172,7 @@ func Setup(ctx *cli.Context) error {
return err 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") 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 { if err := Handler.StartCPUProfile(cpuFile); err != nil {
return err return err
@ -155,14 +182,14 @@ func Setup(ctx *cli.Context) error {
// pprof server // pprof server
if ctx.GlobalBool(pprofFlag.Name) { if ctx.GlobalBool(pprofFlag.Name) {
listenHost := ctx.GlobalString(pprofAddrFlag.Name) listenHost := ctx.GlobalString(pprofAddrFlag.Name)
if ctx.GlobalIsSet(utils.LegacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) { if ctx.GlobalIsSet(legacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) {
listenHost = ctx.GlobalString(utils.LegacyPprofAddrFlag.Name) listenHost = ctx.GlobalString(legacyPprofAddrFlag.Name)
log.Warn("The flag --pprofaddr is deprecated and will be removed in the future, please use --pprof.addr") log.Warn("The flag --pprofaddr is deprecated and will be removed in the future, please use --pprof.addr")
} }
port := ctx.GlobalInt(pprofPortFlag.Name) port := ctx.GlobalInt(pprofPortFlag.Name)
if ctx.GlobalIsSet(utils.LegacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) { if ctx.GlobalIsSet(legacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) {
port = ctx.GlobalInt(utils.LegacyPprofPortFlag.Name) port = ctx.GlobalInt(legacyPprofPortFlag.Name)
log.Warn("The flag --pprofport is deprecated and will be removed in the future, please use --pprof.port") log.Warn("The flag --pprofport is deprecated and will be removed in the future, please use --pprof.port")
} }