ctx not using Global func prefix any longer

This commit is contained in:
Michael Shaw 2022-07-28 12:16:40 -04:00
parent 3e5f8e938e
commit 2f0cdfe4b0
2 changed files with 35 additions and 35 deletions

View File

@ -156,7 +156,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
cfg.Ethstats.URL = ctx.String(utils.EthStatsURLFlag.Name) cfg.Ethstats.URL = ctx.String(utils.EthStatsURLFlag.Name)
} }
applyMetricConfig(ctx, &cfg) applyMetricConfig(ctx, &cfg)
if ctx.GlobalBool(utils.StateDiffFlag.Name) { if ctx.Bool(utils.StateDiffFlag.Name) {
cfg.Eth.Diffing = true cfg.Eth.Diffing = true
} }
@ -192,25 +192,25 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
} }
} }
if ctx.GlobalBool(utils.StateDiffFlag.Name) { if ctx.Bool(utils.StateDiffFlag.Name) {
var indexerConfig interfaces.Config var indexerConfig interfaces.Config
var clientName, nodeID string var clientName, nodeID string
if ctx.GlobalIsSet(utils.StateDiffWritingFlag.Name) { if ctx.IsSet(utils.StateDiffWritingFlag.Name) {
clientName = ctx.GlobalString(utils.StateDiffDBClientNameFlag.Name) clientName = ctx.String(utils.StateDiffDBClientNameFlag.Name)
if ctx.GlobalIsSet(utils.StateDiffDBNodeIDFlag.Name) { if ctx.IsSet(utils.StateDiffDBNodeIDFlag.Name) {
nodeID = ctx.GlobalString(utils.StateDiffDBNodeIDFlag.Name) nodeID = ctx.String(utils.StateDiffDBNodeIDFlag.Name)
} else { } else {
utils.Fatalf("Must specify node ID for statediff DB output") utils.Fatalf("Must specify node ID for statediff DB output")
} }
dbTypeStr := ctx.GlobalString(utils.StateDiffDBTypeFlag.Name) dbTypeStr := ctx.String(utils.StateDiffDBTypeFlag.Name)
dbType, err := shared.ResolveDBType(dbTypeStr) dbType, err := shared.ResolveDBType(dbTypeStr)
if err != nil { if err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
} }
switch dbType { switch dbType {
case shared.FILE: case shared.FILE:
fileModeStr := ctx.GlobalString(utils.StateDiffFileMode.Name) fileModeStr := ctx.String(utils.StateDiffFileMode.Name)
fileMode, err := file.ResolveFileMode(fileModeStr) fileMode, err := file.ResolveFileMode(fileModeStr)
if err != nil { if err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
@ -218,47 +218,47 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
indexerConfig = file.Config{ indexerConfig = file.Config{
Mode: fileMode, Mode: fileMode,
OutputDir: ctx.GlobalString(utils.StateDiffFileCsvDir.Name), OutputDir: ctx.String(utils.StateDiffFileCsvDir.Name),
FilePath: ctx.GlobalString(utils.StateDiffFilePath.Name), FilePath: ctx.String(utils.StateDiffFilePath.Name),
WatchedAddressesFilePath: ctx.GlobalString(utils.StateDiffWatchedAddressesFilePath.Name), WatchedAddressesFilePath: ctx.String(utils.StateDiffWatchedAddressesFilePath.Name),
} }
case shared.POSTGRES: case shared.POSTGRES:
driverTypeStr := ctx.GlobalString(utils.StateDiffDBDriverTypeFlag.Name) driverTypeStr := ctx.String(utils.StateDiffDBDriverTypeFlag.Name)
driverType, err := postgres.ResolveDriverType(driverTypeStr) driverType, err := postgres.ResolveDriverType(driverTypeStr)
if err != nil { if err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
} }
pgConfig := postgres.Config{ pgConfig := postgres.Config{
Hostname: ctx.GlobalString(utils.StateDiffDBHostFlag.Name), Hostname: ctx.String(utils.StateDiffDBHostFlag.Name),
Port: ctx.GlobalInt(utils.StateDiffDBPortFlag.Name), Port: ctx.Int(utils.StateDiffDBPortFlag.Name),
DatabaseName: ctx.GlobalString(utils.StateDiffDBNameFlag.Name), DatabaseName: ctx.String(utils.StateDiffDBNameFlag.Name),
Username: ctx.GlobalString(utils.StateDiffDBUserFlag.Name), Username: ctx.String(utils.StateDiffDBUserFlag.Name),
Password: ctx.GlobalString(utils.StateDiffDBPasswordFlag.Name), Password: ctx.String(utils.StateDiffDBPasswordFlag.Name),
ID: nodeID, ID: nodeID,
ClientName: clientName, ClientName: clientName,
Driver: driverType, Driver: driverType,
} }
if ctx.GlobalIsSet(utils.StateDiffDBMinConns.Name) { if ctx.IsSet(utils.StateDiffDBMinConns.Name) {
pgConfig.MinConns = ctx.GlobalInt(utils.StateDiffDBMinConns.Name) pgConfig.MinConns = ctx.Int(utils.StateDiffDBMinConns.Name)
} }
if ctx.GlobalIsSet(utils.StateDiffDBMaxConns.Name) { if ctx.IsSet(utils.StateDiffDBMaxConns.Name) {
pgConfig.MaxConns = ctx.GlobalInt(utils.StateDiffDBMaxConns.Name) pgConfig.MaxConns = ctx.Int(utils.StateDiffDBMaxConns.Name)
} }
if ctx.GlobalIsSet(utils.StateDiffDBMaxIdleConns.Name) { if ctx.IsSet(utils.StateDiffDBMaxIdleConns.Name) {
pgConfig.MaxIdle = ctx.GlobalInt(utils.StateDiffDBMaxIdleConns.Name) pgConfig.MaxIdle = ctx.Int(utils.StateDiffDBMaxIdleConns.Name)
} }
if ctx.GlobalIsSet(utils.StateDiffDBMaxConnLifetime.Name) { if ctx.IsSet(utils.StateDiffDBMaxConnLifetime.Name) {
pgConfig.MaxConnLifetime = time.Duration(ctx.GlobalDuration(utils.StateDiffDBMaxConnLifetime.Name).Seconds()) pgConfig.MaxConnLifetime = time.Duration(ctx.Duration(utils.StateDiffDBMaxConnLifetime.Name).Seconds())
} }
if ctx.GlobalIsSet(utils.StateDiffDBMaxConnIdleTime.Name) { if ctx.IsSet(utils.StateDiffDBMaxConnIdleTime.Name) {
pgConfig.MaxConnIdleTime = time.Duration(ctx.GlobalDuration(utils.StateDiffDBMaxConnIdleTime.Name).Seconds()) pgConfig.MaxConnIdleTime = time.Duration(ctx.Duration(utils.StateDiffDBMaxConnIdleTime.Name).Seconds())
} }
if ctx.GlobalIsSet(utils.StateDiffDBConnTimeout.Name) { if ctx.IsSet(utils.StateDiffDBConnTimeout.Name) {
pgConfig.ConnTimeout = time.Duration(ctx.GlobalDuration(utils.StateDiffDBConnTimeout.Name).Seconds()) pgConfig.ConnTimeout = time.Duration(ctx.Duration(utils.StateDiffDBConnTimeout.Name).Seconds())
} }
indexerConfig = pgConfig indexerConfig = pgConfig
case shared.DUMP: case shared.DUMP:
dumpTypeStr := ctx.GlobalString(utils.StateDiffDBDumpDst.Name) dumpTypeStr := ctx.String(utils.StateDiffDBDumpDst.Name)
dumpType, err := dumpdb.ResolveDumpType(dumpTypeStr) dumpType, err := dumpdb.ResolveDumpType(dumpTypeStr)
if err != nil { if err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
@ -279,13 +279,13 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
} }
p := statediff.Config{ p := statediff.Config{
IndexerConfig: indexerConfig, IndexerConfig: indexerConfig,
KnownGapsFilePath: ctx.GlobalString(utils.StateDiffKnownGapsFilePath.Name), KnownGapsFilePath: ctx.String(utils.StateDiffKnownGapsFilePath.Name),
ID: nodeID, ID: nodeID,
ClientName: clientName, ClientName: clientName,
Context: context.Background(), Context: context.Background(),
EnableWriteLoop: ctx.GlobalBool(utils.StateDiffWritingFlag.Name), EnableWriteLoop: ctx.Bool(utils.StateDiffWritingFlag.Name),
NumWorkers: ctx.GlobalUint(utils.StateDiffWorkersFlag.Name), NumWorkers: ctx.Uint(utils.StateDiffWorkersFlag.Name),
WaitForSync: ctx.GlobalBool(utils.StateDiffWaitForSync.Name), WaitForSync: ctx.Bool(utils.StateDiffWaitForSync.Name),
} }
utils.RegisterStateDiffService(stack, eth, &cfg.Eth, p, backend) utils.RegisterStateDiffService(stack, eth, &cfg.Eth, p, backend)
} }

View File

@ -1345,7 +1345,7 @@ func setWS(ctx *cli.Context, cfg *node.Config) {
cfg.WSPathPrefix = ctx.String(WSPathPrefixFlag.Name) cfg.WSPathPrefix = ctx.String(WSPathPrefixFlag.Name)
} }
if ctx.GlobalBool(StateDiffFlag.Name) { if ctx.Bool(StateDiffFlag.Name) {
cfg.WSModules = append(cfg.WSModules, "statediff") cfg.WSModules = append(cfg.WSModules, "statediff")
} }
} }