From 0a6130a924840b424fb0625757543527a61f66aa Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 16 Sep 2020 15:27:48 +0300 Subject: [PATCH] [#30] core/object: Make Object constructors similar to RawObject Signed-off-by: Leonard Lyubich --- pkg/core/object/object.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkg/core/object/object.go b/pkg/core/object/object.go index 4f13fce8e7..032db35c86 100644 --- a/pkg/core/object/object.go +++ b/pkg/core/object/object.go @@ -28,17 +28,25 @@ func (o *Object) Address() *object.Address { return nil } -// FromV2 converts v2 Object message to Object. -func FromV2(oV2 *objectV2.Object) *Object { - if oV2 == nil { - return nil - } - +// NewFromV2 constructs Object instance from v2 Object message. +func NewFromV2(obj *objectV2.Object) *Object { return &Object{ - Object: object.NewFromV2(oV2), + Object: object.NewFromV2(obj), } } +// NewFromSDK constructs Object instance from NeoFS SDK Object. +func NewFromSDK(obj *object.Object) *Object { + return &Object{ + Object: obj, + } +} + +// New constructs blank Object instance. +func New() *Object { + return NewFromSDK(object.New()) +} + // FromBytes restores Object from binary format. func FromBytes(data []byte) (*Object, error) { o, err := object.FromBytes(data)