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
55
pkg/morph/client/reputation/wrapper/list.go
Normal file
55
pkg/morph/client/reputation/wrapper/list.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package wrapper
|
||||
|
||||
import (
|
||||
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
|
||||
)
|
||||
|
||||
type (
|
||||
// ReputationID is an ID of the reputation record in reputation contract.
|
||||
ReputationID []byte
|
||||
|
||||
// ListByEpochArgs groups the arguments of
|
||||
// "list reputation ids by epoch" test invoke call.
|
||||
ListByEpochArgs struct {
|
||||
epoch uint64
|
||||
}
|
||||
|
||||
// ListByEpochResult groups the result of "list reputation ids by epoch"
|
||||
// test invoke.
|
||||
ListByEpochResult struct {
|
||||
ids []ReputationID
|
||||
}
|
||||
)
|
||||
|
||||
// SetEpoch sets epoch of expected reputation ids.
|
||||
func (l *ListByEpochArgs) SetEpoch(v uint64) {
|
||||
l.epoch = v
|
||||
}
|
||||
|
||||
// IDs returns slice of reputation id values.
|
||||
func (l ListByEpochResult) IDs() []ReputationID {
|
||||
return l.ids
|
||||
}
|
||||
|
||||
// ListByEpoch invokes the call of "list reputation ids by epoch" method of
|
||||
// reputation contract.
|
||||
func (w *ClientWrapper) ListByEpoch(v ListByEpochArgs) (*ListByEpochResult, error) {
|
||||
args := reputationClient.ListByEpochArgs{}
|
||||
args.SetEpoch(v.epoch)
|
||||
|
||||
data, err := (*reputationClient.Client)(w).ListByEpoch(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids := data.IDs()
|
||||
|
||||
result := make([]ReputationID, 0, len(ids))
|
||||
for i := range ids {
|
||||
result = append(result, ids[i])
|
||||
}
|
||||
|
||||
return &ListByEpochResult{
|
||||
ids: result,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue