From 8a2f5c980ba98e76c3a90550d0c82d756ceb7bf2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 16 Nov 2021 23:56:14 +0300 Subject: [PATCH] [#971] morph/audit: Add optional parameters Add optional parameters to the client call signature. Signed-off-by: Pavel Karpy --- pkg/morph/client/audit/put_result.go | 3 +++ pkg/morph/client/audit/wrapper/result.go | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/morph/client/audit/put_result.go b/pkg/morph/client/audit/put_result.go index feab50b12..ae3070e80 100644 --- a/pkg/morph/client/audit/put_result.go +++ b/pkg/morph/client/audit/put_result.go @@ -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) diff --git a/pkg/morph/client/audit/wrapper/result.go b/pkg/morph/client/audit/wrapper/result.go index 0b947aefd..c09e6263f 100644 --- a/pkg/morph/client/audit/wrapper/result.go +++ b/pkg/morph/client/audit/wrapper/result.go @@ -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)