[#1681] morph/netmap: Support `MaintenanceModeAllowed` config

After recent changes in the NeoFS API protocol network configuration
contains `MaintenanceModeAllowed` boolean flag. There is a need to
support the config value in all NeoFS applications.

Provide `Client.MaintenanceModeAllowed` method which read the config
from the Sidechain. Extend `NetworkConfiguration` structure with
`MaintenanceModeAllowed` field.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
support/v0.34
Leonard Lyubich 2022-09-19 19:39:03 +04:00 committed by fyrchik
parent d2d4191868
commit 0826310b2a
1 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@ const (
irCandidateFeeConfig = "InnerRingCandidateFee"
withdrawFeeConfig = "WithdrawFee"
homomorphicHashingDisabledKey = "HomomorphicHashingDisabled"
maintenanceModeAllowedConfig = "MaintenanceModeAllowed"
)
// MaxObjectSize receives max object size configuration
@ -141,6 +142,15 @@ func (c *Client) WithdrawFee() (uint64, error) {
return fee, nil
}
// MaintenanceModeAllowed reads admission of "maintenance" state from the
// NeoFS network configuration stored in the Sidechain. The admission means
// that storage nodes are allowed to switch their state to "maintenance".
//
// By default, maintenance state is disallowed.
func (c *Client) MaintenanceModeAllowed() (bool, error) {
return c.readBoolConfig(maintenanceModeAllowedConfig)
}
func (c *Client) readUInt64Config(key string) (uint64, error) {
v, err := c.config([]byte(key), IntegerAssert)
if err != nil {
@ -246,6 +256,8 @@ type NetworkConfiguration struct {
HomomorphicHashingDisabled bool
MaintenanceModeAllowed bool
Raw []RawNetworkParameter
}
@ -312,6 +324,8 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
res.WithdrawalFee = bytesToUint64(value)
case homomorphicHashingDisabledKey:
res.HomomorphicHashingDisabled = bytesToBool(value)
case maintenanceModeAllowedConfig:
res.MaintenanceModeAllowed = bytesToBool(value)
}
return nil