From 0826310b2a88a7846d11c8dff712fde0556e88fe Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 19 Sep 2022 19:39:03 +0400 Subject: [PATCH] [#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 --- pkg/morph/client/netmap/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/morph/client/netmap/config.go b/pkg/morph/client/netmap/config.go index 782148e56..b2e902256 100644 --- a/pkg/morph/client/netmap/config.go +++ b/pkg/morph/client/netmap/config.go @@ -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