forked from TrueCloudLab/frostfs-node
[#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 <leonard@nspcc.ru>
This commit is contained in:
parent
21d2f8f861
commit
808ba87e82
2 changed files with 7 additions and 6 deletions
|
@ -3,6 +3,7 @@ package netmap
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-contract/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,9 +37,9 @@ func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
||||||
method += "IR"
|
method += "IR"
|
||||||
}
|
}
|
||||||
|
|
||||||
state := 2
|
state := netmap.OfflineState
|
||||||
if p.online {
|
if p.online {
|
||||||
state = 1
|
state = netmap.OnlineState
|
||||||
}
|
}
|
||||||
|
|
||||||
prm := client.InvokePrm{}
|
prm := client.InvokePrm{}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"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/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"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)
|
return nil, fmt.Errorf("could not get node status: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch v2netmap.NodeState(st) {
|
switch st {
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported node state %d", st)
|
return nil, fmt.Errorf("unsupported node state %d", st)
|
||||||
case v2netmap.Offline:
|
case int64(netmap.OfflineState):
|
||||||
case v2netmap.Online:
|
case int64(netmap.OnlineState):
|
||||||
ev.online = true
|
ev.online = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue