From d58e28afee5f596426cdf7d1425f970beca94579 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 11 Jan 2021 17:36:55 +0300 Subject: [PATCH] [#298] morph/netmap: Use netmap.NodeState argument in UpdatePeerState Replace custom NodeState enum with the one from netmap lib. Remove no longer used NodeState enum. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/netmap.go | 3 +-- pkg/morph/client/netmap/wrapper/update_state.go | 15 +++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 3fea962fc2..2942dc7c8a 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -4,7 +4,6 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/netmap" netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc" crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/event" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" netmapTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/netmap/grpc" @@ -119,7 +118,7 @@ func addNewEpochNotificationHandler(c *cfg, h event.Handler) { func goOffline(c *cfg) { err := c.cfgNetmap.wrapper.UpdatePeerState( crypto.MarshalPublicKey(&c.key.PublicKey), - wrapper.StateOffline, + netmap.NodeStateOffline, ) if err != nil { diff --git a/pkg/morph/client/netmap/wrapper/update_state.go b/pkg/morph/client/netmap/wrapper/update_state.go index ad296f0fec..70902bb326 100644 --- a/pkg/morph/client/netmap/wrapper/update_state.go +++ b/pkg/morph/client/netmap/wrapper/update_state.go @@ -1,26 +1,17 @@ package wrapper import ( + "github.com/nspcc-dev/neofs-api-go/pkg/netmap" contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" "github.com/pkg/errors" ) -// NodeState is a type of node states enumeration. -type NodeState int64 - -const ( - _ NodeState = iota - - // StateOffline is an offline node state value. - StateOffline -) - // UpdatePeerState changes peer status through Netmap contract // call. -func (w *Wrapper) UpdatePeerState(key []byte, state NodeState) error { +func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error { args := contract.UpdateStateArgs{} args.SetPublicKey(key) - args.SetState(int64(state)) + args.SetState(int64(state.ToV2())) // invoke smart contract call //