forked from TrueCloudLab/frostfs-node
[#18] Add invoke helpers for AddPeer and UpdatePeer methods
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
eef20c53df
commit
7bce9a3d87
1 changed files with 33 additions and 2 deletions
|
@ -1,13 +1,23 @@
|
||||||
package invoke
|
package invoke
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
UpdatePeerArgs struct {
|
||||||
|
Key *keys.PublicKey
|
||||||
|
Status uint32
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
getEpochMethod = "epoch"
|
getEpochMethod = "epoch"
|
||||||
setNewEpochMethod = "newEpoch"
|
setNewEpochMethod = "newEpoch"
|
||||||
|
approvePeerMethod = "addPeer"
|
||||||
|
updatePeerStateMethod = "updateState"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Epoch return epoch value from contract.
|
// 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))
|
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),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue