2020-07-24 13:54:03 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-05-18 08:12:51 +00:00
|
|
|
err := c.client.Invoke(
|
2021-01-11 11:54:41 +00:00
|
|
|
c.updateStateMethod,
|
2020-07-24 13:54:03 +00:00
|
|
|
args.state,
|
2021-01-11 11:54:41 +00:00
|
|
|
args.key,
|
2021-05-18 08:12:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", c.updateStateMethod, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|