diff --git a/netmap/network_info.go b/netmap/network_info.go index 035fc37c..f5826214 100644 --- a/netmap/network_info.go +++ b/netmap/network_info.go @@ -75,7 +75,8 @@ func (x *NetworkInfo) readFromV2(m netmap.NetworkInfo, checkFieldPresence bool) configMaxObjSize, configWithdrawalFee: _, err = decodeConfigValueUint64(prm.GetValue()) - case configHomomorphicHashingDisabled: + case configHomomorphicHashingDisabled, + configMaintenanceModeAllowed: _, err = decodeConfigValueBool(prm.GetValue()) } @@ -247,7 +248,8 @@ func (x *NetworkInfo) IterateRawNetworkParameters(f func(name string, value []by configIRCandidateFee, configMaxObjSize, configWithdrawalFee, - configHomomorphicHashingDisabled: + configHomomorphicHashingDisabled, + configMaintenanceModeAllowed: } return false @@ -522,3 +524,20 @@ func (x *NetworkInfo) DisableHomomorphicHashing() { func (x NetworkInfo) HomomorphicHashingDisabled() bool { return x.configBool(configHomomorphicHashingDisabled) } + +const configMaintenanceModeAllowed = "MaintenanceModeAllowed" + +// AllowMaintenanceMode sets the flag allowing nodes to go into maintenance mode. +// +// See also MaintenanceModeAllowed. +func (x *NetworkInfo) AllowMaintenanceMode() { + x.setConfigBool(configMaintenanceModeAllowed, true) +} + +// MaintenanceModeAllowed returns true iff network config allows +// maintenance mode for storage nodes. +// +// Zero NetworkInfo has disallows maintenance mode. +func (x NetworkInfo) MaintenanceModeAllowed() bool { + return x.configBool(configMaintenanceModeAllowed) +} diff --git a/netmap/network_info_test.go b/netmap/network_info_test.go index fc3bbc9b..710e39ad 100644 --- a/netmap/network_info_test.go +++ b/netmap/network_info_test.go @@ -233,3 +233,21 @@ func TestNetworkInfo_HomomorphicHashingDisabled(t *testing.T) { }, ) } + +func TestNetworkInfo_MaintenanceModeAllowed(t *testing.T) { + testConfigValue(t, + func(x NetworkInfo) interface{} { return x.MaintenanceModeAllowed() }, + func(info *NetworkInfo, val interface{}) { + if val.(bool) { + info.AllowMaintenanceMode() + } + }, + true, true, + "MaintenanceModeAllowed", func(val interface{}) []byte { + if val.(bool) { + return []byte{1} + } + return []byte{0} + }, + ) +}