From 9a0964efa4e89f1c091bb55c24e34c3122541e62 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 26 May 2021 13:34:06 +0300 Subject: [PATCH] [#525] morph/container: Accept RemovalWitness in Delete function Make `wrapper.Delete` function to accept `container.RemovalWitness` struct instead of its separated elements. `Signature` type is replaced by binary signature since public key is unused. Signed-off-by: Leonard Lyubich --- pkg/morph/client/container/wrapper/container.go | 11 ++++++----- pkg/services/container/morph/executor.go | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index 7d5be7963..e92d0f96b 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -150,15 +150,16 @@ func (w *Wrapper) Get(cid []byte) (*container.Container, error) { } // Delete marshals container ID, and passes it to Wrapper's Delete method -// along with sig.Key() and sig.Sign(). +// along with signature. // -// Returns error if cid is nil. -func Delete(w *Wrapper, cid *container.ID, sig *pkg.Signature) error { - if cid == nil { +// Returns error if container ID is nil. +func Delete(w *Wrapper, witness core.RemovalWitness) error { + id := witness.ContainerID() + if id == nil { return errNilArgument } - return w.Delete(cid.ToV2().GetValue(), sig.Sign()) + return w.Delete(id.ToV2().GetValue(), witness.Signature()) } // Delete removes the container from NeoFS system diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 69788b65a..d51519b7e 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -11,6 +11,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/session" "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" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container" ) @@ -52,9 +53,14 @@ func (s *morphExecutor) Put(ctx containerSvc.ContextWithToken, body *container.P func (s *morphExecutor) Delete(ctx context.Context, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) { cid := containerSDK.NewIDFromV2(body.GetContainerID()) - sig := pkg.NewSignatureFromV2(body.GetSignature()) + sig := body.GetSignature().GetSign() - err := wrapper.Delete(s.wrapper, cid, sig) + var rmWitness containercore.RemovalWitness + + rmWitness.SetContainerID(cid) + rmWitness.SetSignature(sig) + + err := wrapper.Delete(s.wrapper, rmWitness) if err != nil { return nil, err }