forked from TrueCloudLab/frostfs-node
923f84722a
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package audit
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
auditAPI "github.com/TrueCloudLab/frostfs-sdk-go/audit"
|
|
)
|
|
|
|
// GetAuditResult returns audit result structure stored in audit contract.
|
|
func (c *Client) GetAuditResult(id ResultID) (*auditAPI.Result, error) {
|
|
prm := client.TestInvokePrm{}
|
|
prm.SetMethod(getResultMethod)
|
|
prm.SetArgs([]byte(id))
|
|
|
|
prms, err := c.client.TestInvoke(prm)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getResultMethod, err)
|
|
} else if ln := len(prms); ln != 1 {
|
|
return nil, fmt.Errorf("unexpected stack item count (%s): %d", getResultMethod, ln)
|
|
}
|
|
|
|
value, err := client.BytesFromStackItem(prms[0])
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", getResultMethod, err)
|
|
}
|
|
|
|
var auditRes auditAPI.Result
|
|
if err := auditRes.Unmarshal(value); err != nil {
|
|
return nil, fmt.Errorf("could not unmarshal audit result structure: %w", err)
|
|
}
|
|
|
|
return &auditRes, nil
|
|
}
|