forked from TrueCloudLab/frostfs-node
[#525] morph/container: Do not accept signature in Put function
In previous implementation wrapper over the Container contract's client accepted the signature of the container in addition to itself. After recent changes in API Go lib container carries its signature. Thus, it is redundant to pass the container signature separately. Make `wrapper.Put` method to accept `Container` only. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
df197dc38b
commit
32828d2b90
2 changed files with 9 additions and 4 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||||
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
|
@ -22,7 +23,7 @@ var (
|
||||||
// along with sig.Key() and sig.Sign().
|
// along with sig.Key() and sig.Sign().
|
||||||
//
|
//
|
||||||
// Returns error if container is nil.
|
// Returns error if container is nil.
|
||||||
func Put(w *Wrapper, cnr *container.Container, sig *pkg.Signature) (*container.ID, error) {
|
func Put(w *Wrapper, cnr *container.Container) (*cid.ID, error) {
|
||||||
if cnr == nil {
|
if cnr == nil {
|
||||||
return nil, errNilArgument
|
return nil, errNilArgument
|
||||||
}
|
}
|
||||||
|
@ -32,12 +33,14 @@ func Put(w *Wrapper, cnr *container.Container, sig *pkg.Signature) (*container.I
|
||||||
return nil, fmt.Errorf("can't marshal container: %w", err)
|
return nil, fmt.Errorf("can't marshal container: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sig := cnr.Signature()
|
||||||
|
|
||||||
err = w.Put(data, sig.Key(), sig.Sign())
|
err = w.Put(data, sig.Key(), sig.Sign())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(sha256.Sum256(data))
|
id.SetSHA256(sha256.Sum256(data))
|
||||||
|
|
||||||
return id, nil
|
return id, nil
|
||||||
|
|
|
@ -30,9 +30,11 @@ func (s *morphExecutor) Put(ctx context.Context, body *container.PutRequestBody)
|
||||||
return nil, fmt.Errorf("invalid format of the container structure: %w", err)
|
return nil, fmt.Errorf("invalid format of the container structure: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig := body.GetSignature()
|
cnr.SetSignature(
|
||||||
|
pkg.NewSignatureFromV2(body.GetSignature()),
|
||||||
|
)
|
||||||
|
|
||||||
cid, err := wrapper.Put(s.wrapper, cnr, pkg.NewSignatureFromV2(sig))
|
cid, err := wrapper.Put(s.wrapper, cnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue