From c16a31ef3e66b41dec3bfe0fdcac2a802726a69a Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 10 Oct 2022 22:10:49 +0300 Subject: [PATCH] [#1329] node: Set undefined netmap status by default It allows general usage of `controlNetmapStatus` getter: does not matter of handler (`NewEpoch` handler of initial setter). Signed-off-by: Pavel Karpy --- cmd/neofs-node/netmap.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 31761b8b..43a46c18 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -35,8 +35,12 @@ type networkState struct { } func newNetworkState() *networkState { + var nmStatus atomic.Value + nmStatus.Store(control.NetmapStatus_STATUS_UNDEFINED) + return &networkState{ - epoch: atomic.NewUint64(0), + epoch: atomic.NewUint64(0), + controlNetStatus: nmStatus, } } @@ -83,7 +87,7 @@ func (s *networkState) setNodeInfo(ni *netmapSDK.NodeInfo) { s.controlNetStatus.Store(ctrlNetSt) } -func (s *networkState) controlNetmapStatus() control.NetmapStatus { +func (s *networkState) controlNetmapStatus() (res control.NetmapStatus) { return s.controlNetStatus.Load().(control.NetmapStatus) }