forked from TrueCloudLab/frostfs-node
[#1367] adm: Support homomorphic hashing config
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
4a316ceae9
commit
b3272e7cf1
1 changed files with 18 additions and 1 deletions
|
@ -188,7 +188,7 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
|
|||
|
||||
v, err := tuple[1].TryBytes()
|
||||
if err != nil {
|
||||
return errors.New("invalid config value from netmap contract")
|
||||
return invalidConfigValueErr(k)
|
||||
}
|
||||
|
||||
switch string(k) {
|
||||
|
@ -203,6 +203,13 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
|
|||
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%d (int)\n", k, n)))
|
||||
case netmapEigenTrustAlphaKey:
|
||||
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (str)\n", k, v)))
|
||||
case netmapHomomorphicHashDisabledKey:
|
||||
vBool, err := tuple[1].TryBool()
|
||||
if err != nil {
|
||||
return invalidConfigValueErr(k)
|
||||
}
|
||||
|
||||
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%t (bool)\n", k, vBool)))
|
||||
default:
|
||||
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (hex)\n", k, hex.EncodeToString(v))))
|
||||
}
|
||||
|
@ -288,6 +295,12 @@ func parseConfigPair(kvStr string, force bool) (key string, val interface{}, err
|
|||
}
|
||||
|
||||
val = valRaw
|
||||
case netmapHomomorphicHashDisabledKey:
|
||||
val, err = strconv.ParseBool(valRaw)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("could not parse %s's value '%s' as bool: %w", key, valRaw, err)
|
||||
}
|
||||
|
||||
default:
|
||||
if !force {
|
||||
return "", nil, fmt.Errorf(
|
||||
|
@ -300,3 +313,7 @@ func parseConfigPair(kvStr string, force bool) (key string, val interface{}, err
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func invalidConfigValueErr(key []byte) error {
|
||||
return fmt.Errorf("invalid %s config value from netmap contract", key)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue