Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Dec 29, 2023
1 parent bfd7eb9 commit 1424558
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 55 deletions.
30 changes: 30 additions & 0 deletions object/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (h *SplitHeader) ToGRPCMessage() grpc.Message {
m.SetParentSignature(h.parSig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetChildren(refs.ObjectIDListToGRPCMessage(h.children))
m.SetSplitId(h.splitID)
m.SetInit(h.init.ToGRPCMessage().(*refsGRPC.ObjectID))
}

return m
Expand Down Expand Up @@ -224,6 +225,20 @@ func (h *SplitHeader) FromGRPCMessage(m grpc.Message) error {
}
}

init := v.GetInit()
if init == nil {
h.init = nil
} else {
if h.init == nil {
h.init = new(refs.ObjectID)

Check warning on line 233 in object/convert.go

View check run for this annotation

Codecov / codecov/patch

object/convert.go#L232-L233

Added lines #L232 - L233 were not covered by tests
}

err = h.init.FromGRPCMessage(init)
if err != nil {
return err

Check warning on line 238 in object/convert.go

View check run for this annotation

Codecov / codecov/patch

object/convert.go#L236-L238

Added lines #L236 - L238 were not covered by tests
}
}

parHdr := v.GetParentHeader()
if parHdr == nil {
h.parHdr = nil
Expand Down Expand Up @@ -529,6 +544,7 @@ func (s *SplitInfo) ToGRPCMessage() grpc.Message {

m.SetLastPart(s.lastPart.ToGRPCMessage().(*refsGRPC.ObjectID))
m.SetLink(s.link.ToGRPCMessage().(*refsGRPC.ObjectID))
m.SetInitPart(s.initPart.ToGRPCMessage().(*refsGRPC.ObjectID))
m.SetSplitId(s.splitID)
}

Expand Down Expand Up @@ -571,6 +587,20 @@ func (s *SplitInfo) FromGRPCMessage(m grpc.Message) error {
}
}

init := v.GetInitPart()
if init == nil {
s.initPart = nil
} else {
if s.initPart == nil {
s.initPart = new(refs.ObjectID)

Check warning on line 595 in object/convert.go

View check run for this annotation

Codecov / codecov/patch

object/convert.go#L594-L595

Added lines #L594 - L595 were not covered by tests
}

err = s.initPart.FromGRPCMessage(init)
if err != nil {
return err

Check warning on line 600 in object/convert.go

View check run for this annotation

Codecov / codecov/patch

object/convert.go#L598-L600

Added lines #L598 - L600 were not covered by tests
}
}

s.splitID = v.GetSplitId()

return nil
Expand Down
9 changes: 9 additions & 0 deletions object/grpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (m *Header_Split) SetSplitId(v []byte) {
m.SplitId = v
}

func (m *Header_Split) SetInit(v *refs.ObjectID) {
m.Init = v
}

// SetContainerId sets identifier of the container.
func (m *Header) SetContainerId(v *refs.ContainerID) {
m.ContainerId = v
Expand Down Expand Up @@ -170,6 +174,11 @@ func (m *SplitInfo) SetLink(v *refs.ObjectID) {
m.Link = v
}

// SetInitPart sets id of initializing object in split hierarchy.
func (m *SplitInfo) SetInitPart(v *refs.ObjectID) {
m.InitPart = v
}

// FromString parses ObjectType from a string representation,
// It is a reverse action to String().
//
Expand Down
132 changes: 80 additions & 52 deletions object/grpc/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions object/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
splitHdrParentHeaderField = 4
splitHdrChildrenField = 5
splitHdrSplitIDField = 6
splitHdrInitIDField = 7

hdrVersionField = 1
hdrContainerIDField = 2
Expand All @@ -49,6 +50,7 @@ const (
splitInfoSplitIDField = 1
splitInfoLastPartField = 2
splitInfoLinkField = 3
splitInfoInitField = 4

getReqBodyAddressField = 1
getReqBodyRawFlagField = 2
Expand Down Expand Up @@ -202,7 +204,8 @@ func (h *SplitHeader) StableMarshal(buf []byte) []byte {
offset += proto.NestedStructureMarshal(splitHdrParentSignatureField, buf[offset:], h.parSig)
offset += proto.NestedStructureMarshal(splitHdrParentHeaderField, buf[offset:], h.parHdr)
offset += refs.ObjectIDNestedListMarshal(splitHdrChildrenField, buf[offset:], h.children)
proto.BytesMarshal(splitHdrSplitIDField, buf[offset:], h.splitID)
offset += proto.BytesMarshal(splitHdrSplitIDField, buf[offset:], h.splitID)
proto.NestedStructureMarshal(splitHdrInitIDField, buf[offset:], h.init)

return buf
}
Expand All @@ -218,6 +221,7 @@ func (h *SplitHeader) StableSize() (size int) {
size += proto.NestedStructureSize(splitHdrParentHeaderField, h.parHdr)
size += refs.ObjectIDNestedListSize(splitHdrChildrenField, h.children)
size += proto.BytesSize(splitHdrSplitIDField, h.splitID)
size += proto.NestedStructureSize(splitHdrInitIDField, h.init)

return size
}
Expand Down Expand Up @@ -363,7 +367,8 @@ func (s *SplitInfo) StableMarshal(buf []byte) []byte {

offset += proto.BytesMarshal(splitInfoSplitIDField, buf[offset:], s.splitID)
offset += proto.NestedStructureMarshal(splitInfoLastPartField, buf[offset:], s.lastPart)
proto.NestedStructureMarshal(splitInfoLinkField, buf[offset:], s.link)
offset += proto.NestedStructureMarshal(splitInfoLinkField, buf[offset:], s.link)
proto.NestedStructureMarshal(splitInfoInitField, buf[offset:], s.initPart)

return buf
}
Expand All @@ -376,6 +381,7 @@ func (s *SplitInfo) StableSize() (size int) {
size += proto.BytesSize(splitInfoSplitIDField, s.splitID)
size += proto.NestedStructureSize(splitInfoLastPartField, s.lastPart)
size += proto.NestedStructureSize(splitInfoLinkField, s.link)
size += proto.NestedStructureSize(splitInfoInitField, s.initPart)

return size
}
Expand Down
Loading

0 comments on commit 1424558

Please sign in to comment.