[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-26 13:34:06 +03:00 committed by Leonard Lyubich
parent d691a20d52
commit 9a0964efa4
2 changed files with 14 additions and 7 deletions

View file

@ -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 // 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. // Returns error if container ID is nil.
func Delete(w *Wrapper, cid *container.ID, sig *pkg.Signature) error { func Delete(w *Wrapper, witness core.RemovalWitness) error {
if cid == nil { id := witness.ContainerID()
if id == nil {
return errNilArgument 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 // Delete removes the container from NeoFS system

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/session" "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/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"
"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"
) )
@ -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) { func (s *morphExecutor) Delete(ctx context.Context, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) {
cid := containerSDK.NewIDFromV2(body.GetContainerID()) 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 { if err != nil {
return nil, err return nil, err
} }