Some checks failed
DCO action / DCO (pull_request) Successful in 48s
Tests and linters / Tests (1.19) (pull_request) Failing after 59s
Tests and linters / Tests with -race (pull_request) Successful in 1m31s
Tests and linters / Tests (1.20) (pull_request) Failing after 5m52s
Tests and linters / Lint (pull_request) Successful in 7m3s
* Use protowire.AppendTag to encode a tag and append it * Use protowire.AppendVarint to append numeric data * Use protowire.AppendBytes and protowire.AppendString Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
package audit
|
|
|
|
import (
|
|
audit "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/audit/grpc"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
|
)
|
|
|
|
const (
|
|
_ = iota
|
|
versionFNum
|
|
auditEpochFNum
|
|
cidFNum
|
|
pubKeyFNum
|
|
completeFNum
|
|
requestsFNum
|
|
retriesFNum
|
|
passSGFNum
|
|
failSGFNum
|
|
hitFNum
|
|
missFNum
|
|
failFNum
|
|
passNodesFNum
|
|
failNodesFNum
|
|
)
|
|
|
|
// StableMarshal marshals unified DataAuditResult structure into a protobuf
|
|
// binary format without field order shuffle.
|
|
func (a *DataAuditResult) StableMarshal(buf []byte) []byte {
|
|
if a == nil {
|
|
return []byte{}
|
|
}
|
|
|
|
if buf == nil {
|
|
buf = make([]byte, 0, a.StableSize())
|
|
}
|
|
|
|
buf = proto.NestedStructureMarshal(versionFNum, buf, a.version)
|
|
buf = proto.Fixed64Marshal(auditEpochFNum, buf, a.auditEpoch)
|
|
buf = proto.NestedStructureMarshal(cidFNum, buf, a.cid)
|
|
buf = proto.BytesMarshal(pubKeyFNum, buf, a.pubKey)
|
|
buf = proto.BoolMarshal(completeFNum, buf, a.complete)
|
|
buf = proto.UInt32Marshal(requestsFNum, buf, a.requests)
|
|
buf = proto.UInt32Marshal(retriesFNum, buf, a.retries)
|
|
buf = refs.ObjectIDNestedListMarshal(passSGFNum, buf, a.passSG)
|
|
buf = refs.ObjectIDNestedListMarshal(failSGFNum, buf, a.failSG)
|
|
buf = proto.UInt32Marshal(hitFNum, buf, a.hit)
|
|
buf = proto.UInt32Marshal(missFNum, buf, a.miss)
|
|
buf = proto.UInt32Marshal(failFNum, buf, a.fail)
|
|
buf = proto.RepeatedBytesMarshal(passNodesFNum, buf, a.passNodes)
|
|
buf = proto.RepeatedBytesMarshal(failNodesFNum, buf, a.failNodes)
|
|
|
|
return buf
|
|
}
|
|
|
|
// StableSize returns byte length of DataAuditResult structure
|
|
// marshaled by StableMarshal function.
|
|
func (a *DataAuditResult) StableSize() (size int) {
|
|
if a == nil {
|
|
return 0
|
|
}
|
|
|
|
size += proto.NestedStructureSize(versionFNum, a.version)
|
|
size += proto.Fixed64Size(auditEpochFNum, a.auditEpoch)
|
|
size += proto.NestedStructureSize(cidFNum, a.cid)
|
|
size += proto.BytesSize(pubKeyFNum, a.pubKey)
|
|
size += proto.BoolSize(completeFNum, a.complete)
|
|
size += proto.UInt32Size(requestsFNum, a.requests)
|
|
size += proto.UInt32Size(retriesFNum, a.retries)
|
|
size += refs.ObjectIDNestedListSize(passSGFNum, a.passSG)
|
|
size += refs.ObjectIDNestedListSize(failSGFNum, a.failSG)
|
|
size += proto.UInt32Size(hitFNum, a.hit)
|
|
size += proto.UInt32Size(missFNum, a.miss)
|
|
size += proto.UInt32Size(failFNum, a.fail)
|
|
size += proto.RepeatedBytesSize(passNodesFNum, a.passNodes)
|
|
size += proto.RepeatedBytesSize(failNodesFNum, a.failNodes)
|
|
|
|
return size
|
|
}
|
|
|
|
// Unmarshal unmarshals DataAuditResult structure from its protobuf
|
|
// binary representation.
|
|
func (a *DataAuditResult) Unmarshal(data []byte) error {
|
|
return message.Unmarshal(a, data, new(audit.DataAuditResult))
|
|
}
|