[#1367] adm: Support homomorphic hashing config in dump-config

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-06 23:33:50 +03:00 committed by Evgenii Stratonikov
parent e0e4f1f7ee
commit 83dd963ab7

View file

@ -184,7 +184,7 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
v, err := tuple[1].TryBytes() v, err := tuple[1].TryBytes()
if err != nil { if err != nil {
return errors.New("invalid config value from netmap contract") return invalidConfigValueErr(k)
} }
switch string(k) { switch string(k) {
@ -199,6 +199,13 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%d (int)\n", k, n))) _, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%d (int)\n", k, n)))
case netmapEigenTrustAlphaKey: case netmapEigenTrustAlphaKey:
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (str)\n", k, v))) _, _ = 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: default:
_, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (hex)\n", k, hex.EncodeToString(v)))) _, _ = tw.Write([]byte(fmt.Sprintf("%s:\t%s (hex)\n", k, hex.EncodeToString(v))))
} }
@ -209,3 +216,7 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
return nil return nil
} }
func invalidConfigValueErr(key []byte) error {
return fmt.Errorf("invalid %s config value from netmap contract", key)
}