frostfs-node/pkg/morph/client/netmap/update_state.go
Evgenii Stratonikov 71b87155ef [] *: use stdlib errors package
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-05-19 16:42:54 +03:00

40 lines
769 B
Go

package netmap
import (
"fmt"
)
// 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 {
err := c.client.Invoke(
c.updateStateMethod,
args.state,
args.key,
)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.updateStateMethod, err)
}
return nil
}