Skip to content

Commit 028af34

Browse files
rjl493456442fjl
authored andcommitted
cmd/utils: fix command line flag resolve (#20167)
In Geth, we have two sources for configuration: (1) Config file (2) Command line flag Basically geth will first resolve config file and then overwrite configs with command line flags. This issue is: geth should only overwrite configs if flags are truly set. So before we apply any flag to configs, `GlobalIsSet` check is necessary.
1 parent a73f3f4 commit 028af34

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎cmd/utils/flags.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
14531453
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
14541454
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
14551455
}
1456-
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == "archive"
1457-
cfg.NoPrefetch = ctx.GlobalBool(CacheNoPrefetchFlag.Name)
1458-
1456+
if ctx.GlobalIsSet(GCModeFlag.Name) {
1457+
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == "archive"
1458+
}
1459+
if ctx.GlobalIsSet(CacheNoPrefetchFlag.Name) {
1460+
cfg.NoPrefetch = ctx.GlobalBool(CacheNoPrefetchFlag.Name)
1461+
}
14591462
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheTrieFlag.Name) {
14601463
cfg.TrieCleanCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheTrieFlag.Name) / 100
14611464
}

0 commit comments

Comments
 (0)