forked from TrueCloudLab/frostfs-node
[#85] inner-ring/container: Check container format in process Put
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
766eea4c8c
commit
a8e9d15f3f
1 changed files with 32 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
|
v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||||
|
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||||
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -14,10 +19,36 @@ func (cp *Processor) processContainerPut(put *containerEvent.Put) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cnrData := put.Container()
|
||||||
|
|
||||||
|
// unmarshal container structure
|
||||||
|
// FIXME: temp solution, replace after neofs-api-go#168
|
||||||
|
cnrProto := new(containerGRPC.Container)
|
||||||
|
if err := proto.Unmarshal(cnrData, cnrProto); err != nil {
|
||||||
|
cp.log.Info("could not unmarshal container structure",
|
||||||
|
zap.String("error", err.Error()),
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cnr := containerSDK.NewContainerFromV2(
|
||||||
|
v2container.ContainerFromGRPCMessage(cnrProto),
|
||||||
|
)
|
||||||
|
|
||||||
|
// perform format check
|
||||||
|
if err := container.CheckFormat(cnr); err != nil {
|
||||||
|
cp.log.Info("container with incorrect format detected",
|
||||||
|
zap.String("error", err.Error()),
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err := invoke.RegisterContainer(cp.morphClient, cp.containerContract,
|
err := invoke.RegisterContainer(cp.morphClient, cp.containerContract,
|
||||||
&invoke.ContainerParams{
|
&invoke.ContainerParams{
|
||||||
Key: put.PublicKey(),
|
Key: put.PublicKey(),
|
||||||
Container: put.Container(),
|
Container: cnrData,
|
||||||
Signature: put.Signature(),
|
Signature: put.Signature(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue