mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
params: fix param value decoding
This commit is contained in:
parent
cf8af42646
commit
336a2dab56
2 changed files with 7 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"maps"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -171,7 +172,10 @@ func (cfg *Config2) UnmarshalJSON(input []byte) error {
|
|||
return fmt.Errorf("expected JSON object for chain configuration")
|
||||
}
|
||||
// Now we're in the object.
|
||||
newcfg := Config2{activation: Activations{}}
|
||||
newcfg := Config2{
|
||||
activation: make(Activations),
|
||||
param: make(map[int]any),
|
||||
}
|
||||
for {
|
||||
tok, err = dec.Token()
|
||||
if tok == json.Delim('}') {
|
||||
|
|
@ -227,7 +231,7 @@ func (cfg *Config2) decodeParameter(key string, dec *json.Decoder) error {
|
|||
if err := dec.Decode(v); err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.param[id] = v
|
||||
cfg.param[id] = reflect.ValueOf(v).Elem().Interface()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ func Define[V any](def T[V]) Parameter[V] {
|
|||
optional: def.Optional,
|
||||
defaultValue: def.Default,
|
||||
new: func() any {
|
||||
var z V
|
||||
return z
|
||||
return new(V)
|
||||
},
|
||||
validate: func(v any, cfg *Config2) error {
|
||||
if def.Validate == nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue