[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-11 17:36:55 +03:00 committed by Alex Vanin
parent b45360b933
commit d58e28afee
2 changed files with 4 additions and 14 deletions

View file

@ -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 {

View file

@ -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
//