mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 11:31:02 +00:00
internal/flags: fix --miner.gasprice default listing (#28932)
This commit is contained in:
parent
19af9008f1
commit
8ec638dc5e
@ -257,6 +257,7 @@ type BigFlag struct {
|
|||||||
HasBeenSet bool
|
HasBeenSet bool
|
||||||
|
|
||||||
Value *big.Int
|
Value *big.Int
|
||||||
|
defaultValue *big.Int
|
||||||
|
|
||||||
Aliases []string
|
Aliases []string
|
||||||
EnvVars []string
|
EnvVars []string
|
||||||
@ -269,6 +270,10 @@ func (f *BigFlag) IsSet() bool { return f.HasBeenSet }
|
|||||||
func (f *BigFlag) String() string { return cli.FlagStringer(f) }
|
func (f *BigFlag) String() string { return cli.FlagStringer(f) }
|
||||||
|
|
||||||
func (f *BigFlag) Apply(set *flag.FlagSet) error {
|
func (f *BigFlag) Apply(set *flag.FlagSet) error {
|
||||||
|
// Set default value so that environment wont be able to overwrite it
|
||||||
|
if f.Value != nil {
|
||||||
|
f.defaultValue = new(big.Int).Set(f.Value)
|
||||||
|
}
|
||||||
for _, envVar := range f.EnvVars {
|
for _, envVar := range f.EnvVars {
|
||||||
envVar = strings.TrimSpace(envVar)
|
envVar = strings.TrimSpace(envVar)
|
||||||
if value, found := syscall.Getenv(envVar); found {
|
if value, found := syscall.Getenv(envVar); found {
|
||||||
@ -283,7 +288,6 @@ func (f *BigFlag) Apply(set *flag.FlagSet) error {
|
|||||||
f.Value = new(big.Int)
|
f.Value = new(big.Int)
|
||||||
set.Var((*bigValue)(f.Value), f.Name, f.Usage)
|
set.Var((*bigValue)(f.Value), f.Name, f.Usage)
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +314,7 @@ func (f *BigFlag) GetDefaultText() string {
|
|||||||
if f.DefaultText != "" {
|
if f.DefaultText != "" {
|
||||||
return f.DefaultText
|
return f.DefaultText
|
||||||
}
|
}
|
||||||
return f.GetValue()
|
return f.defaultValue.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// bigValue turns *big.Int into a flag.Value
|
// bigValue turns *big.Int into a flag.Value
|
||||||
|
Loading…
Reference in New Issue
Block a user