[#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:
parent
a3e0a9f74c
commit
766eea4c8c
1 changed files with 6 additions and 0 deletions
|
@ -8,9 +8,11 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"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/container"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
"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"
|
containerMorph "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container"
|
containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type morphExecutor struct {
|
type morphExecutor struct {
|
||||||
|
@ -33,6 +35,10 @@ func (s *morphExecutor) Put(ctx context.Context, body *container.PutRequestBody)
|
||||||
cnr := containerSDK.NewContainerFromV2(body.GetContainer())
|
cnr := containerSDK.NewContainerFromV2(body.GetContainer())
|
||||||
sig := body.GetSignature()
|
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())
|
cid, err := s.wrapper.Put(cnr, sig.GetKey(), sig.GetSign())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue