forked from TrueCloudLab/frostfs-node
[#452] morph/client: Add reputation contract client wrapper
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9f1a49a562
commit
b9a1aaec23
4 changed files with 204 additions and 0 deletions
51
pkg/morph/client/reputation/wrapper/put.go
Normal file
51
pkg/morph/client/reputation/wrapper/put.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
||||
)
|
||||
|
||||
type (
|
||||
// PutArgs groups the arguments of "put reputation value" invocation call.
|
||||
PutArgs struct {
|
||||
epoch uint64
|
||||
peerID reputation.PeerID
|
||||
value []byte // todo: replace with struct
|
||||
}
|
||||
)
|
||||
|
||||
// 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 reputation.PeerID) {
|
||||
p.peerID = v
|
||||
}
|
||||
|
||||
// SetValue sets reputation value.
|
||||
func (p *PutArgs) SetValue(v []byte) {
|
||||
p.value = v
|
||||
}
|
||||
|
||||
// Put invokes direct call of "put reputation value" method of reputation contract.
|
||||
func (w *ClientWrapper) Put(v PutArgs) error {
|
||||
args := reputationClient.PutArgs{}
|
||||
args.SetEpoch(v.epoch)
|
||||
args.SetPeerID(v.peerID.Bytes())
|
||||
args.SetValue(v.value) // todo: marshal reputation value to `value` bytes there
|
||||
|
||||
return (*reputationClient.Client)(w).Put(args)
|
||||
}
|
||||
|
||||
// PutViaNotary invokes notary call of "put reputation value" method of
|
||||
// reputation contract.
|
||||
func (w *ClientWrapper) PutViaNotary(v PutArgs) error {
|
||||
args := reputationClient.PutArgs{}
|
||||
args.SetEpoch(v.epoch)
|
||||
args.SetPeerID(v.peerID.Bytes())
|
||||
args.SetValue(v.value) // todo: marshal reputation value to `value` bytes there
|
||||
|
||||
return (*reputationClient.Client)(w).PutViaNotary(args)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue