[#1680] morph/netmap: Pre-refactor processing of node states

New network status of storage nodes is going to be introduced. To
simplify the addition, it would be useful to prepare the code for this.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-09-19 17:38:07 +04:00 committed by fyrchik
parent 4c94faac67
commit 42fb40e841
4 changed files with 30 additions and 10 deletions

View file

@ -12,10 +12,16 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
)
// TODO: enum can become redundant after neofs-contract#270
const (
_ int8 = iota
stateOnline
)
type UpdatePeer struct {
publicKey *keys.PublicKey
online bool
state int8 // state enum value
// For notary notifications only.
// Contains raw transactions of notary request.
@ -26,7 +32,7 @@ type UpdatePeer struct {
func (UpdatePeer) MorphEvent() {}
func (s UpdatePeer) Online() bool {
return s.online
return s.state == stateOnline
}
func (s UpdatePeer) PublicKey() *keys.PublicKey {
@ -78,7 +84,7 @@ func ParseUpdatePeer(e *state.ContainedNotificationEvent) (event.Event, error) {
return nil, fmt.Errorf("unsupported node state %d", st)
case int64(netmap.OfflineState):
case int64(netmap.OnlineState):
ev.online = true
ev.state = stateOnline
}
return ev, nil