[#1365] morph: Add HomomorphicHashDisabled config getter

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-04-29 20:47:14 +03:00 committed by fyrchik
parent ae86d2907c
commit fa9c910648

View file

@ -20,6 +20,7 @@ const (
etAlphaConfig = "EigenTrustAlpha" etAlphaConfig = "EigenTrustAlpha"
irCandidateFeeConfig = "InnerRingCandidateFee" irCandidateFeeConfig = "InnerRingCandidateFee"
withdrawFeeConfig = "WithdrawFee" withdrawFeeConfig = "WithdrawFee"
homomorphicHashingDisabledKey = "HomomorphicHashingDisabled"
) )
// MaxObjectSize receives max object size configuration // MaxObjectSize receives max object size configuration
@ -109,6 +110,17 @@ func (c *Client) EigenTrustAlpha() (float64, error) {
return strconv.ParseFloat(strAlpha, 64) return strconv.ParseFloat(strAlpha, 64)
} }
// HomomorphicHashDisabled returns global configuration value of homomorphic hashing
// settings.
func (c *Client) HomomorphicHashDisabled() (bool, error) {
hashingDisabled, err := c.readBoolConfig(homomorphicHashingDisabledKey)
if err != nil {
return false, fmt.Errorf("(%T) could not get homomorphic hash state: %w", c, err)
}
return hashingDisabled, nil
}
// InnerRingCandidateFee returns global configuration value of fee paid by // InnerRingCandidateFee returns global configuration value of fee paid by
// node to be in inner ring candidates list. // node to be in inner ring candidates list.
func (c *Client) InnerRingCandidateFee() (uint64, error) { func (c *Client) InnerRingCandidateFee() (uint64, error) {
@ -151,6 +163,16 @@ func (c *Client) readStringConfig(key string) (string, error) {
return v.(string), nil return v.(string), nil
} }
func (c *Client) readBoolConfig(key string) (bool, error) {
v, err := c.config([]byte(key), BoolAssert)
if err != nil {
return false, err
}
// BoolAssert is guaranteed to return bool if the error is nil.
return v.(bool), nil
}
// SetConfigPrm groups parameters of SetConfig operation. // SetConfigPrm groups parameters of SetConfig operation.
type SetConfigPrm struct { type SetConfigPrm struct {
id []byte id []byte
@ -328,6 +350,11 @@ func StringAssert(item stackitem.Item) (interface{}, error) {
return client.StringFromStackItem(item) return client.StringFromStackItem(item)
} }
// BoolAssert converts stack item to bool.
func BoolAssert(item stackitem.Item) (interface{}, error) {
return client.BoolFromStackItem(item)
}
// iterateRecords iterates over all config records and passes them to f. // iterateRecords iterates over all config records and passes them to f.
// //
// Returns f's errors directly. // Returns f's errors directly.