From 9b0eef0d436222a1241555a340f2d622e61152aa Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 4 Sep 2020 13:04:24 +0300 Subject: [PATCH] [#135] sdk/object: Add Release method to RawObject Implement Release method that converts RawObject to read-only finalized Object instance. Remove ToV2 method overriding from Object. Signed-off-by: Leonard Lyubich --- pkg/object/object.go | 7 ------- pkg/object/raw.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/object/object.go b/pkg/object/object.go index be1f5b8b..2d96002d 100644 --- a/pkg/object/object.go +++ b/pkg/object/object.go @@ -117,13 +117,6 @@ func (o *Object) CutPayload() *Object { return nil } -// ToV2 converts object to v2 Object message. -func (o *Object) ToV2() *object.Object { - obj, _ := o.rwObject.ToV2(nil) - - return obj -} - func (o *rwObject) v2Header() *object.Header { hV2 := new(object.Header) hV2.SetContainerID(o.cid.ToV2()) diff --git a/pkg/object/raw.go b/pkg/object/raw.go index c82ba5cc..ffd9f21c 100644 --- a/pkg/object/raw.go +++ b/pkg/object/raw.go @@ -38,6 +38,17 @@ func (o *RawObject) SetOwnerID(v *owner.ID) { } } +// Release returns read-only Object instance. +func (o *RawObject) Release() *Object { + if o != nil { + return &Object{ + rwObject: o.rwObject, + } + } + + return nil +} + // SetPayloadChecksumSHA256 sets payload checksum as a SHA256 checksum. func (o *RawObject) SetPayloadChecksumSHA256(v [sha256.Size]byte) { if o != nil {