[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-04 13:04:24 +03:00 committed by Stanislav Bogatyrev
parent 8e9d456038
commit 9b0eef0d43
2 changed files with 11 additions and 7 deletions

View file

@ -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())

View file

@ -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 {