[#85] services/container: Check container format in Put

Call CheckFormat function in container.Put handler for conducting initial
checks of the structure that are not performed by the smart contract.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-03 12:08:24 +03:00 committed by Leonard Lyubich
parent a3e0a9f74c
commit 766eea4c8c

View file

@ -8,9 +8,11 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/v2/container"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
containerCore "github.com/nspcc-dev/neofs-node/pkg/core/container"
containerMorph "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container"
"github.com/pkg/errors"
)
type morphExecutor struct {
@ -33,6 +35,10 @@ func (s *morphExecutor) Put(ctx context.Context, body *container.PutRequestBody)
cnr := containerSDK.NewContainerFromV2(body.GetContainer())
sig := body.GetSignature()
if err := containerCore.CheckFormat(cnr); err != nil {
return nil, errors.Wrapf(err, "incorrect container format")
}
cid, err := s.wrapper.Put(cnr, sig.GetKey(), sig.GetSign())
if err != nil {
return nil, err