From 808ba87e8201a6dad9c814b16e66e6635abd20e6 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 16 Jun 2022 14:20:03 +0300 Subject: [PATCH] [#1513] morph/netmap: Use node state constants from `Netmap` contract `Netmap` contract exports enumeration of the node states. Replace using literals and constants from NeoFS API Go V2 with the values provided by contract. Signed-off-by: Leonard Lyubich --- pkg/morph/client/netmap/update_state.go | 5 +++-- pkg/morph/event/netmap/update_peer.go | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/morph/client/netmap/update_state.go b/pkg/morph/client/netmap/update_state.go index e6c8cca71..1b860ffe6 100644 --- a/pkg/morph/client/netmap/update_state.go +++ b/pkg/morph/client/netmap/update_state.go @@ -3,6 +3,7 @@ package netmap import ( "fmt" + "github.com/nspcc-dev/neofs-contract/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) @@ -36,9 +37,9 @@ func (c *Client) UpdatePeerState(p UpdatePeerPrm) error { method += "IR" } - state := 2 + state := netmap.OfflineState if p.online { - state = 1 + state = netmap.OnlineState } prm := client.InvokePrm{} diff --git a/pkg/morph/event/netmap/update_peer.go b/pkg/morph/event/netmap/update_peer.go index e7fd5fcfd..83037a595 100644 --- a/pkg/morph/event/netmap/update_peer.go +++ b/pkg/morph/event/netmap/update_peer.go @@ -7,7 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" - v2netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap" + "github.com/nspcc-dev/neofs-contract/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -73,11 +73,11 @@ func ParseUpdatePeer(e *subscriptions.NotificationEvent) (event.Event, error) { return nil, fmt.Errorf("could not get node status: %w", err) } - switch v2netmap.NodeState(st) { + switch st { default: return nil, fmt.Errorf("unsupported node state %d", st) - case v2netmap.Offline: - case v2netmap.Online: + case int64(netmap.OfflineState): + case int64(netmap.OnlineState): ev.online = true }