[#135] sdk/object: Fix IDFromV2 nil-behavior

Remove nil if-statement from IDFromV2 function to which avoids checking the
correctness of the identifier format. From now IDFromV2 returns format error
on nil argument.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-04 12:16:08 +03:00 committed by Stanislav Bogatyrev
parent 59f804faa2
commit 047bae63d0

View file

@ -37,10 +37,6 @@ func (id *ID) ToV2() *refs.ObjectID {
// Returns an error if the format of the identifier // Returns an error if the format of the identifier
// in the message is broken. // in the message is broken.
func IDFromV2(idV2 *refs.ObjectID) (*ID, error) { func IDFromV2(idV2 *refs.ObjectID) (*ID, error) {
if idV2 == nil {
return nil, nil
}
val := idV2.GetValue() val := idV2.GetValue()
if ln := len(val); ln != sha256.Size { if ln := len(val); ln != sha256.Size {
return nil, errors.Errorf("could not convert %T to %T: invalid length %d", return nil, errors.Errorf("could not convert %T to %T: invalid length %d",