From 7bce9a3d8708fdfe4b7179292c482fce89017f55 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 3 Sep 2020 17:32:37 +0300 Subject: [PATCH] [#18] Add invoke helpers for AddPeer and UpdatePeer methods Signed-off-by: Alex Vanin --- pkg/innerring/invoke/netmap.go | 35 ++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/pkg/innerring/invoke/netmap.go b/pkg/innerring/invoke/netmap.go index 7c6cf23a9..37beab59a 100644 --- a/pkg/innerring/invoke/netmap.go +++ b/pkg/innerring/invoke/netmap.go @@ -1,13 +1,23 @@ package invoke import ( + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) +type ( + UpdatePeerArgs struct { + Key *keys.PublicKey + Status uint32 + } +) + const ( - getEpochMethod = "epoch" - setNewEpochMethod = "newEpoch" + getEpochMethod = "epoch" + setNewEpochMethod = "newEpoch" + approvePeerMethod = "addPeer" + updatePeerStateMethod = "updateState" ) // Epoch return epoch value from contract. @@ -37,3 +47,24 @@ func SetNewEpoch(cli *client.Client, con util.Uint160, epoch uint64) error { return cli.Invoke(con, extraFee, setNewEpochMethod, int64(epoch)) } + +// ApprovePeer invokes AddPeer method. +func ApprovePeer(cli *client.Client, con util.Uint160, peer []byte) error { + if cli == nil { + return client.ErrNilClient + } + + return cli.Invoke(con, extraFee, approvePeerMethod, peer) +} + +// UpdatePeerState invokes AddPeer method. +func UpdatePeerState(cli *client.Client, con util.Uint160, args *UpdatePeerArgs) error { + if cli == nil { + return client.ErrNilClient + } + + return cli.Invoke(con, extraFee, updatePeerStateMethod, + args.Key.Bytes(), + int64(args.Status), + ) +}