diff --git a/v2/object/convert.go b/v2/object/convert.go index 51a2cd83..07686895 100644 --- a/v2/object/convert.go +++ b/v2/object/convert.go @@ -135,6 +135,8 @@ func SplitHeaderToGRPCMessage(h *SplitHeader) *object.Header_Split { m.SetChildren(childMsg) + m.SetSplitId(h.GetSplitID()) + return m } @@ -170,6 +172,8 @@ func SplitHeaderFromGRPCMessage(m *object.Header_Split) *SplitHeader { h.SetChildren(children) + h.SetSplitID(m.GetSplitId()) + return h } diff --git a/v2/object/marshal.go b/v2/object/marshal.go index b59419e9..4e54b34c 100644 --- a/v2/object/marshal.go +++ b/v2/object/marshal.go @@ -21,6 +21,7 @@ const ( splitHdrParentSignatureField = 3 splitHdrParentHeaderField = 4 splitHdrChildrenField = 5 + splitHdrSplitIDField = 6 hdrVersionField = 1 hdrContainerIDField = 2 @@ -275,6 +276,11 @@ func (h *SplitHeader) StableMarshal(buf []byte) ([]byte, error) { offset += n } + _, err = proto.BytesMarshal(splitHdrSplitIDField, buf[offset:], h.splitID) + if err != nil { + return nil, err + } + return buf, nil } @@ -292,6 +298,8 @@ func (h *SplitHeader) StableSize() (size int) { size += proto.NestedStructureSize(splitHdrChildrenField, h.children[i]) } + size += proto.BytesSize(splitHdrSplitIDField, h.splitID) + return size } diff --git a/v2/object/marshal_test.go b/v2/object/marshal_test.go index efd5df30..7f811af0 100644 --- a/v2/object/marshal_test.go +++ b/v2/object/marshal_test.go @@ -461,6 +461,7 @@ func generateSplit(sig string) *object.SplitHeader { split.SetParent(generateObjectID("Parent")) split.SetParentSignature(generateSignature("Key", sig)) split.SetPrevious(generateObjectID("Previous")) + split.SetSplitID([]byte("UUIDv4")) return split } diff --git a/v2/object/types.go b/v2/object/types.go index d5b37ef2..6898cf6f 100644 --- a/v2/object/types.go +++ b/v2/object/types.go @@ -33,6 +33,8 @@ type SplitHeader struct { parHdr *Header children []*refs.ObjectID + + splitID []byte } type Header struct { @@ -380,6 +382,20 @@ func (h *SplitHeader) SetChildren(v []*refs.ObjectID) { } } +func (h *SplitHeader) GetSplitID() []byte { + if h != nil { + return h.splitID + } + + return nil +} + +func (h *SplitHeader) SetSplitID(v []byte) { + if h != nil { + h.splitID = v + } +} + func (h *Header) GetVersion() *refs.Version { if h != nil { return h.version