From 02be6c83a62efb33c5634b0e336bd7a4b08a2fe5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Sat, 16 Oct 2021 13:17:25 +0300 Subject: [PATCH] morph/client: update morph container wrapper Signed-off-by: Evgenii Stratonikov --- .../client/container/wrapper/container.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index 806c2c96..45fcbdbf 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "errors" "fmt" + "strings" v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs" core "github.com/nspcc-dev/neofs-node/pkg/core/container" @@ -165,16 +166,19 @@ func (w *Wrapper) Get(cid []byte) (*container.Container, error) { // ask RPC neo node to get serialized container rpcAnswer, err := w.client.Get(args) if err != nil { + // TODO(fyrchik): reuse messages from container contract. + // Currently there are some dependency problems: + // github.com/nspcc-dev/neofs-node/pkg/innerring imports + // github.com/nspcc-dev/neofs-sdk-go/audit imports + // github.com/nspcc-dev/neofs-api-go/v2/audit: ambiguous import: found package github.com/nspcc-dev/neofs-api-go/v2/audit in multiple modules: + // github.com/nspcc-dev/neofs-api-go v1.27.1 (/home/dzeta/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.27.1/v2/audit) + // github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1 (/home/dzeta/go/pkg/mod/github.com/nspcc-dev/neofs-api-go/v2@v2.11.0-pre.0.20211201134523-3604d96f3fe1/audit) + if strings.Contains(err.Error(), "container does not exist") { + return nil, core.ErrNotFound + } return nil, err } - // In #37 we've decided to remove length check, because smart contract would - // fail on casting `nil` value from storage to `[]byte` producing FAULT state. - // Apparently it does not fail, so we have to check length explicitly. - if len(rpcAnswer.Container()) == 0 { - return nil, core.ErrNotFound - } - // unmarshal container cnr := container.New() if err := cnr.Unmarshal(rpcAnswer.Container()); err != nil {