[#505] morph/container: Do not return ID from Wrapper.Put method

`Put` method of the wrapper over the Container contract's client does not
modify passed binary container, so it makes no sense to calculate the
identifier.

`Put` method returns the error only from now. Function `Put` calculates
identifier itself since it is still required by function signature.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-19 18:39:05 +03:00 committed by Alex Vanin
parent 565ad51b42
commit 3a5849fadb

View file

@ -32,7 +32,15 @@ func Put(w *Wrapper, cnr *container.Container, sig *pkg.Signature) (*container.I
return nil, fmt.Errorf("can't marshal container: %w", err)
}
return w.Put(data, sig.Key(), sig.Sign())
err = w.Put(data, sig.Key(), sig.Sign())
if err != nil {
return nil, err
}
id := container.NewID()
id.SetSHA256(sha256.Sum256(data))
return id, nil
}
// Put saves binary container with its key and signature
@ -40,9 +48,9 @@ func Put(w *Wrapper, cnr *container.Container, sig *pkg.Signature) (*container.I
//
// Returns calculated container identifier and any error
// encountered that caused the saving to interrupt.
func (w *Wrapper) Put(cnr, key, sig []byte) (*container.ID, error) {
func (w *Wrapper) Put(cnr, key, sig []byte) error {
if len(sig) == 0 || len(key) == 0 {
return nil, errNilArgument
return errNilArgument
}
var args client.PutArgs
@ -53,13 +61,10 @@ func (w *Wrapper) Put(cnr, key, sig []byte) (*container.ID, error) {
err := w.client.Put(args)
if err != nil {
return nil, err
return err
}
id := container.NewID()
id.SetSHA256(sha256.Sum256(cnr))
return id, nil
return nil
}
// Get reads the container from NeoFS system by identifier