-
Notifications
You must be signed in to change notification settings - Fork 38
/
put.go
45 lines (37 loc) · 1012 Bytes
/
put.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package reputation
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-sdk-go/reputation"
)
type (
// PutPrm groups the arguments of "put reputation value" invocation call.
PutPrm struct {
epoch uint64
peerID reputation.PeerID
value reputation.GlobalTrust
}
)
// SetEpoch sets epoch of reputation value.
func (p *PutPrm) SetEpoch(v uint64) {
p.epoch = v
}
// SetPeerID sets peer id of reputation value.
func (p *PutPrm) SetPeerID(v reputation.PeerID) {
p.peerID = v
}
// SetValue sets reputation value.
func (p *PutPrm) SetValue(v reputation.GlobalTrust) {
p.value = v
}
// Put invokes direct call of "put reputation value" method of reputation contract.
func (c *Client) Put(p PutPrm) error {
prm := client.InvokePrm{}
prm.SetMethod(putMethod)
prm.SetArgs(p.epoch, p.peerID.PublicKey(), p.value.Marshal())
err := c.client.Invoke(prm)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", putMethod, err)
}
return nil
}