From 0803bc6ded0097443d626c20a4d399cea7ef8868 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Thu, 16 May 2024 12:03:42 +0300 Subject: [PATCH] [#83] object: Regenerate protobufs for `ECHeader` * Fix marshalers and converters; * Fix unit-tests. Signed-off-by: Airat Arifullin --- object/convert.go | 18 ++++++++++++++++-- object/grpc/types.pb.go | Bin 51227 -> 51762 bytes object/marshal.go | 18 +++++++++--------- object/test/generate.go | 2 +- object/types.go | 14 +++++++------- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/object/convert.go b/object/convert.go index 5b4acda..99047dc 100644 --- a/object/convert.go +++ b/object/convert.go @@ -270,7 +270,7 @@ func (h *ECHeader) ToGRPCMessage() grpc.Message { m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID) m.ParentSplitId = h.ParentSplitID - m.ParentSplitIndex = h.ParentSplitIndex + m.ParentSplitParentId = h.ParentSplitParentID.ToGRPCMessage().(*refsGRPC.ObjectID) m.Index = h.Index m.Total = h.Total m.Header = h.Header @@ -303,7 +303,21 @@ func (h *ECHeader) FromGRPCMessage(m grpc.Message) error { } h.ParentSplitID = v.GetParentSplitId() - h.ParentSplitIndex = v.GetParentSplitIndex() + + parSplitParentID := v.GetParentSplitParentId() + if parSplitParentID == nil { + h.ParentSplitParentID = nil + } else { + if h.ParentSplitParentID == nil { + h.ParentSplitParentID = new(refs.ObjectID) + } + + err = h.ParentSplitParentID.FromGRPCMessage(parSplitParentID) + if err != nil { + return err + } + } + h.Index = v.GetIndex() h.Total = v.GetTotal() h.Header = v.GetHeader() diff --git a/object/grpc/types.pb.go b/object/grpc/types.pb.go index 254e76d54648f5eea7ac4d52b6fc05b6b1be79a5..3cb44a3dc5c5cc4e35e99aa51b929af2f8cf9940 100644 GIT binary patch delta 1324 zcmZux-)~c87!ITD*4pWQlp+qgZ>HIB>AJS-j}Y_aR9J!jbz z%`hRxNw?5FbuH_l-9~i~m0=TzMdL`kCDaSK6Zi{odSi@<@%z3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4(d(IZ&T^i!fQ{E3KPWA7@$Lb^COmXI flnU;cJRjfVN^Hkf$8Chrh(A9Y&ySUFXQ%%Gl>B6t diff --git a/object/marshal.go b/object/marshal.go index fa2de95..bf8fcb9 100644 --- a/object/marshal.go +++ b/object/marshal.go @@ -26,13 +26,13 @@ const ( splitHdrChildrenField = 5 splitHdrSplitIDField = 6 - ecHdrParentField = 1 - ecHdrIndexField = 2 - ecHdrTotalField = 3 - ecHdrHeaderLengthField = 4 - ecHdrHeaderField = 5 - ecHdrParentSplitID = 6 - ecHdrParentSplitIndex = 7 + ecHdrParentField = 1 + ecHdrIndexField = 2 + ecHdrTotalField = 3 + ecHdrHeaderLengthField = 4 + ecHdrHeaderField = 5 + ecHdrParentSplitID = 6 + ecHdrParentSplitParentID = 7 hdrVersionField = 1 hdrContainerIDField = 2 @@ -264,7 +264,7 @@ func (h *ECHeader) StableMarshal(buf []byte) []byte { offset += proto.UInt32Marshal(ecHdrHeaderLengthField, buf[offset:], h.HeaderLength) offset += proto.BytesMarshal(ecHdrHeaderField, buf[offset:], h.Header) offset += proto.BytesMarshal(ecHdrParentSplitID, buf[offset:], h.ParentSplitID) - proto.UInt32Marshal(ecHdrParentSplitIndex, buf[offset:], h.ParentSplitIndex) + proto.NestedStructureMarshal(ecHdrParentSplitParentID, buf[offset:], h.ParentSplitParentID) return buf } @@ -279,7 +279,7 @@ func (h *ECHeader) StableSize() (size int) { size += proto.UInt32Size(ecHdrHeaderLengthField, h.HeaderLength) size += proto.BytesSize(ecHdrHeaderField, h.Header) size += proto.BytesSize(ecHdrParentSplitID, h.ParentSplitID) - size += proto.UInt32Size(ecHdrParentSplitIndex, h.ParentSplitIndex) + size += proto.NestedStructureSize(ecHdrParentSplitParentID, h.ParentSplitParentID) return size } diff --git a/object/test/generate.go b/object/test/generate.go index bb774cc..95c76e5 100644 --- a/object/test/generate.go +++ b/object/test/generate.go @@ -92,7 +92,7 @@ func GenerateECHeader(empty bool) *object.ECHeader { if !empty { ech.Parent = refstest.GenerateObjectID(empty) ech.ParentSplitID = []byte{1, 2, 3} - ech.ParentSplitIndex = 1 + ech.ParentSplitParentID = refstest.GenerateObjectID(empty) ech.Index = 0 ech.Total = 2 ech.Header = []byte("chunk of ec-encoded parent header") diff --git a/object/types.go b/object/types.go index c9a0519..7916b1e 100644 --- a/object/types.go +++ b/object/types.go @@ -40,13 +40,13 @@ type SplitHeader struct { } type ECHeader struct { - Parent *refs.ObjectID - ParentSplitID []byte - ParentSplitIndex uint32 - Index uint32 - Total uint32 - Header []byte - HeaderLength uint32 + Parent *refs.ObjectID + ParentSplitID []byte + ParentSplitParentID *refs.ObjectID + Index uint32 + Total uint32 + Header []byte + HeaderLength uint32 } type Header struct {