[#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" "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc" netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
crypto "github.com/nspcc-dev/neofs-crypto" 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" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
netmapTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/netmap/grpc" 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) { func goOffline(c *cfg) {
err := c.cfgNetmap.wrapper.UpdatePeerState( err := c.cfgNetmap.wrapper.UpdatePeerState(
crypto.MarshalPublicKey(&c.key.PublicKey), crypto.MarshalPublicKey(&c.key.PublicKey),
wrapper.StateOffline, netmap.NodeStateOffline,
) )
if err != nil { if err != nil {

View file

@ -1,26 +1,17 @@
package wrapper package wrapper
import ( import (
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors" "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 // UpdatePeerState changes peer status through Netmap contract
// call. // call.
func (w *Wrapper) UpdatePeerState(key []byte, state NodeState) error { func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error {
args := contract.UpdateStateArgs{} args := contract.UpdateStateArgs{}
args.SetPublicKey(key) args.SetPublicKey(key)
args.SetState(int64(state)) args.SetState(int64(state.ToV2()))
// invoke smart contract call // invoke smart contract call
// //