forked from TrueCloudLab/frostfs-node
[#1377] oid, cid: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f65898a354
commit
f15e6e888f
118 changed files with 1455 additions and 886 deletions
|
@ -1,6 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
|
@ -22,9 +23,12 @@ func Delete(c *Client, witness core.RemovalWitness) error {
|
|||
return fmt.Errorf("could not marshal session token: %w", err)
|
||||
}
|
||||
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
id.Encode(binCnr)
|
||||
|
||||
return c.Delete(
|
||||
DeletePrm{
|
||||
cid: id.ToV2().GetValue(),
|
||||
cid: binCnr,
|
||||
signature: witness.Signature(),
|
||||
token: binToken,
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
|
@ -13,19 +14,17 @@ import (
|
|||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
// through Container contract call.
|
||||
func (c *Client) GetEACL(cid *cid.ID) (*eacl.Table, error) {
|
||||
if cid == nil {
|
||||
func (c *Client) GetEACL(cnr *cid.ID) (*eacl.Table, error) {
|
||||
if cnr == nil {
|
||||
return nil, errNilArgument
|
||||
}
|
||||
|
||||
v2 := cid.ToV2()
|
||||
if v2 == nil {
|
||||
return nil, errUnsupported // use other major version if there any
|
||||
}
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
cnr.Encode(binCnr)
|
||||
|
||||
prm := client.TestInvokePrm{}
|
||||
prm.SetMethod(eaclMethod)
|
||||
prm.SetArgs(v2.GetValue())
|
||||
prm.SetArgs(binCnr)
|
||||
|
||||
prms, err := c.client.TestInvoke(prm)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
@ -29,8 +30,11 @@ func AsContainerSource(w *Client) core.Source {
|
|||
// Get marshals container ID, and passes it to Wrapper's Get method.
|
||||
//
|
||||
// Returns error if cid is nil.
|
||||
func Get(c *Client, cid *cid.ID) (*container.Container, error) {
|
||||
return c.Get(cid.ToV2().GetValue())
|
||||
func Get(c *Client, cnr *cid.ID) (*container.Container, error) {
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
cnr.Encode(binCnr)
|
||||
|
||||
return c.Get(binCnr)
|
||||
}
|
||||
|
||||
// Get reads the container from NeoFS system by binary identifier
|
||||
|
|
|
@ -3,7 +3,6 @@ package container
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
|
@ -48,10 +47,14 @@ func (c *Client) List(ownerID *owner.ID) ([]*cid.ID, error) {
|
|||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", listMethod, err)
|
||||
}
|
||||
|
||||
v2 := new(v2refs.ContainerID)
|
||||
v2.SetValue(rawCid)
|
||||
var id cid.ID
|
||||
|
||||
cidList = append(cidList, cid.NewFromV2(v2))
|
||||
err = id.Decode(rawCid)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode container ID: %w", err)
|
||||
}
|
||||
|
||||
cidList = append(cidList, &id)
|
||||
}
|
||||
|
||||
return cidList, nil
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
|
@ -32,14 +34,17 @@ func (a2 *AnnounceLoadPrm) SetReporter(key []byte) {
|
|||
//
|
||||
// Returns any error encountered that caused the saving to interrupt.
|
||||
func (c *Client) AnnounceLoad(p AnnounceLoadPrm) error {
|
||||
v2 := p.a.ContainerID().ToV2()
|
||||
if v2 == nil {
|
||||
return errUnsupported // use other major version if there any
|
||||
cnr, ok := p.a.ContainerID()
|
||||
if !ok {
|
||||
return errors.New("missing container for load announcement")
|
||||
}
|
||||
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
cnr.Encode(binCnr)
|
||||
|
||||
prm := client.InvokePrm{}
|
||||
prm.SetMethod(putSizeMethod)
|
||||
prm.SetArgs(p.a.Epoch(), v2.GetValue(), p.a.UsedSpace(), p.key)
|
||||
prm.SetArgs(p.a.Epoch(), binCnr, p.a.UsedSpace(), p.key)
|
||||
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||
|
||||
err := c.client.Invoke(prm)
|
||||
|
@ -130,10 +135,17 @@ func (c *Client) GetUsedSpaceEstimations(id EstimationID) (*Estimations, error)
|
|||
return nil, fmt.Errorf("could not get estimation list array from stack item (%s): %w", getSizeMethod, err)
|
||||
}
|
||||
|
||||
var cnr cid.ID
|
||||
|
||||
err = cnr.Decode(rawCID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode container ID: %w", err)
|
||||
}
|
||||
|
||||
v2 := new(v2refs.ContainerID)
|
||||
v2.SetValue(rawCID)
|
||||
res := &Estimations{
|
||||
ContainerID: cid.NewFromV2(v2),
|
||||
ContainerID: &cnr,
|
||||
Values: make([]Estimation, 0, len(prms)),
|
||||
}
|
||||
|
||||
|
|
|
@ -44,10 +44,10 @@ func Put(c *Client, cnr *container.Container) (*cid.ID, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
id := cid.New()
|
||||
var id cid.ID
|
||||
id.SetSHA256(sha256.Sum256(data))
|
||||
|
||||
return id, nil
|
||||
return &id, nil
|
||||
}
|
||||
|
||||
// PutPrm groups parameters of Put operation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue