frostfs-node/pkg/morph/client/reputation/put.go
Evgenii Stratonikov 3c5b62d839 [#625] morph/client: make method names constant
We don't use custom names and the only place where custom method option
is used it provides the default name and can be omitted.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-02-01 15:47:54 +03:00

44 lines
915 B
Go

package reputation
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
)
// PutArgs groups the arguments of "put reputation value" invocation call.
type PutArgs struct {
epoch uint64
peerID []byte
value []byte
}
// SetEpoch sets epoch of reputation value.
func (p *PutArgs) SetEpoch(v uint64) {
p.epoch = v
}
// SetPeerID sets peer id of reputation value.
func (p *PutArgs) SetPeerID(v []byte) {
p.peerID = v
}
// SetValue sets marshaled reputation value.
func (p *PutArgs) SetValue(v []byte) {
p.value = v
}
// Put invokes direct call of "put reputation value" method of reputation contract.
func (c *Client) Put(args PutArgs) error {
prm := client.InvokePrm{}
prm.SetMethod(putMethod)
prm.SetArgs(int64(args.epoch), args.peerID, args.value)
err := c.client.Invoke(prm)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", putMethod, err)
}
return nil
}