cmd/utils: fix handling of boolean flags when they are set to false (#33338)

geth --nodiscover=false  
may result in ctx.IsSet(NoDiscoverFlag.Name) is true, but cfg.
NoDiscovery should be false, not true.
This commit is contained in:
cui 2025-12-02 23:11:56 +08:00 committed by GitHub
parent 042c47ce1a
commit be94ea1c40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1374,7 +1374,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
cfg.MaxPendingPeers = ctx.Int(MaxPendingPeersFlag.Name) cfg.MaxPendingPeers = ctx.Int(MaxPendingPeersFlag.Name)
} }
if ctx.IsSet(NoDiscoverFlag.Name) { if ctx.IsSet(NoDiscoverFlag.Name) {
cfg.NoDiscovery = true cfg.NoDiscovery = ctx.Bool(NoDiscoverFlag.Name)
} }
flags.CheckExclusive(ctx, DiscoveryV4Flag, NoDiscoverFlag) flags.CheckExclusive(ctx, DiscoveryV4Flag, NoDiscoverFlag)
@ -1724,7 +1724,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.LogHistory = ctx.Uint64(LogHistoryFlag.Name) cfg.LogHistory = ctx.Uint64(LogHistoryFlag.Name)
} }
if ctx.IsSet(LogNoHistoryFlag.Name) { if ctx.IsSet(LogNoHistoryFlag.Name) {
cfg.LogNoHistory = true cfg.LogNoHistory = ctx.Bool(LogNoHistoryFlag.Name)
} }
if ctx.IsSet(LogSlowBlockFlag.Name) { if ctx.IsSet(LogSlowBlockFlag.Name) {
cfg.SlowBlockThreshold = ctx.Duration(LogSlowBlockFlag.Name) cfg.SlowBlockThreshold = ctx.Duration(LogSlowBlockFlag.Name)