2020-12-21 13:47:02 +00:00
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
|
|
auditAPI "github.com/TrueCloudLab/frostfs-sdk-go/audit"
|
2020-12-21 13:47:02 +00:00
|
|
|
)
|
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
// ResultID is an identity of audit result inside audit contract.
|
|
|
|
type ResultID []byte
|
|
|
|
|
|
|
|
// PutPrm groups parameters of PutAuditResult operation.
|
|
|
|
type PutPrm struct {
|
|
|
|
result *auditAPI.Result
|
2021-11-16 20:56:14 +00:00
|
|
|
|
|
|
|
client.InvokePrmOptional
|
2020-12-21 13:47:02 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
// SetResult sets audit result.
|
|
|
|
func (p *PutPrm) SetResult(result *auditAPI.Result) {
|
|
|
|
p.result = result
|
2020-12-21 13:47:02 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
// PutAuditResult saves passed audit result structure in NeoFS system
|
|
|
|
// through Audit contract call.
|
|
|
|
//
|
|
|
|
// Returns encountered error that caused the saving to interrupt.
|
|
|
|
func (c *Client) PutAuditResult(p PutPrm) error {
|
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(putResultMethod)
|
2022-05-11 10:26:22 +00:00
|
|
|
prm.SetArgs(p.result.Marshal())
|
2022-01-31 12:32:51 +00:00
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
2021-05-18 08:12:51 +00:00
|
|
|
|
2022-05-11 10:26:22 +00:00
|
|
|
err := c.client.Invoke(prm)
|
2021-05-18 08:12:51 +00:00
|
|
|
if err != nil {
|
2022-01-29 13:06:36 +00:00
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", putResultMethod, err)
|
2021-05-18 08:12:51 +00:00
|
|
|
}
|
|
|
|
return nil
|
2020-12-21 13:47:02 +00:00
|
|
|
}
|