[#145] sdk/object: Refactor logic of field setters

In previous implementation RawObject constructor initialized internal v2
Object structure recursively so that further you can directly set the values
of nested fields. This caused the object created by constructor New to be
different from the object created from the empty object v2.

Remove recursive initialization of v2 Object from New and NewRaw
constructors. Make setters to initialize nested structures on demand.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-16 14:16:58 +03:00 committed by Stanislav Bogatyrev
parent 052a4a97dc
commit 1ac6f2eeeb
3 changed files with 61 additions and 55 deletions

View file

@ -26,7 +26,7 @@ func NewFromV2(oV2 *object.Object) *Object {
//
// Works similar as NewFromV2(new(Object)).
func New() *Object {
return NewFromV2(initObjectRecursive())
return NewFromV2(new(object.Object))
}
// ToV2 converts Object to v2 Object message.