frostfs-node/pkg/morph/client/reputation/put.go
Leonard Lyubich 8d201f920e [#496] morph/wrappers: Deprecate all notary-dedicated methods
All client wrappers should use underlying static client with enabled notary
work mode in order to produce invocations of notary contract.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-25 16:35:52 +03:00

61 lines
1.2 KiB
Go

package reputation
import (
"fmt"
)
// 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 {
err := c.client.Invoke(
c.putMethod,
int64(args.epoch),
args.peerID,
args.value,
)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
}
return nil
}
// PutViaNotary invokes notary call of "put reputation value" method of
// reputation contract.
//
// Deprecated: construct underlying StaticClient with TryNotary() option
// and use Put.
func (c *Client) PutViaNotary(args PutArgs) error {
err := c.client.NotaryInvoke(
c.putMethod,
int64(args.epoch),
args.peerID,
args.value,
)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.putMethod, err)
}
return err
}