2020-07-24 13:54:03 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2020-07-24 13:54:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// UpdateStateArgs groups the arguments
|
|
|
|
// of update state invocation call.
|
|
|
|
type UpdateStateArgs struct {
|
|
|
|
key []byte // peer public key
|
|
|
|
|
|
|
|
state int64 // new peer state
|
2021-11-10 10:44:19 +00:00
|
|
|
|
|
|
|
client.InvokePrmOptional
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetPublicKey sets peer public key
|
|
|
|
// in a binary format.
|
|
|
|
func (u *UpdateStateArgs) SetPublicKey(v []byte) {
|
|
|
|
u.key = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetState sets the new peer state.
|
|
|
|
func (u *UpdateStateArgs) SetState(v int64) {
|
|
|
|
u.state = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateState invokes the call of update state method
|
|
|
|
// of NeoFS Netmap contract.
|
|
|
|
func (c *Client) UpdateState(args UpdateStateArgs) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
|
|
|
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(updateStateMethod)
|
2021-11-09 20:52:29 +00:00
|
|
|
prm.SetArgs(args.state, args.key)
|
2021-11-10 10:44:19 +00:00
|
|
|
prm.InvokePrmOptional = args.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
err := c.client.Invoke(prm)
|
2021-05-18 08:12:51 +00:00
|
|
|
if err != nil {
|
2022-01-29 13:06:36 +00:00
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", updateStateMethod, err)
|
2021-05-18 08:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|