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 254e76d..3cb44a3 100644 Binary files a/object/grpc/types.pb.go and b/object/grpc/types.pb.go differ 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 {