[#971] morph/audit: Add optional parameters

Add optional parameters to the client call
signature.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-16 23:56:14 +03:00 committed by Alex Vanin
parent ed4810a020
commit 8a2f5c980b
2 changed files with 19 additions and 2 deletions

View file

@ -10,6 +10,8 @@ import (
// of "put audit result" invocation call.
type PutAuditResultArgs struct {
rawResult []byte // audit result in NeoFS API-compatible binary representation
client.InvokePrmOptional
}
// SetRawResult sets audit result structure
@ -25,6 +27,7 @@ func (c *Client) PutAuditResult(args PutAuditResultArgs) error {
prm.SetMethod(c.putResultMethod)
prm.SetArgs(args.rawResult)
prm.InvokePrmOptional = args.InvokePrmOptional
err := c.client.Invoke(prm)

View file

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -14,18 +15,31 @@ type ResultID []byte
var errUnsupported = errors.New("unsupported structure version")
// PutPrm groups parameters of PutAuditResult operation.
type PutPrm struct {
result *auditAPI.Result
client.InvokePrmOptional
}
// SetResult sets audit result.
func (p *PutPrm) SetResult(result *auditAPI.Result) {
p.result = result
}
// PutAuditResult saves passed audit result structure in NeoFS system
// through Audit contract call.
//
// Returns encountered error that caused the saving to interrupt.
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
rawResult, err := result.Marshal()
func (w *ClientWrapper) PutAuditResult(prm PutPrm) error {
rawResult, err := prm.result.Marshal()
if err != nil {
return fmt.Errorf("could not marshal audit result: %w", err)
}
args := audit.PutAuditResultArgs{}
args.SetRawResult(rawResult)
args.InvokePrmOptional = prm.InvokePrmOptional
return w.client.
PutAuditResult(args)