[#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 <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-10-10 22:10:49 +03:00 committed by fyrchik
parent f4a3fa2977
commit c16a31ef3e

View file

@ -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),
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)
}