[#132] sdk/object: Add payload field to Object

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-02 14:48:25 +03:00 committed by Stanislav Bogatyrev
parent e222c441e5
commit f18e8535c5

View file

@ -39,6 +39,8 @@ type rwObject struct {
payloadChecksum *refs.Checksum
payload []byte
// TODO: add other fields
}
@ -75,6 +77,14 @@ func (o *Object) Verify() error {
return nil
}
func (o *Object) GetPayload() []byte {
if o != nil {
return o.payload
}
return nil
}
// ToV2 converts object to v2 Object message.
func (o *Object) ToV2() *object.Object {
obj, _ := o.rwObject.ToV2(nil)
@ -147,6 +157,7 @@ func (o *rwObject) ToV2(key *ecdsa.PrivateKey) (*object.Object, error) {
obj := new(object.Object)
obj.SetObjectID(o.id.ToV2())
obj.SetHeader(hdr)
obj.SetPayload(o.payload)
sig := new(refs.Signature)
sig.SetKey(o.key)
@ -195,6 +206,7 @@ func FromV2(oV2 *object.Object) (*Object, error) {
cid: cid,
ownerID: ownerID,
payloadChecksum: hdr.GetPayloadHash(),
payload: oV2.GetPayload(),
},
}, nil
}