forked from TrueCloudLab/frostfs-node
[#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes: * avoid package-colliding variable naming * avoid using pointers to IDs where unnecessary * avoid using `idSDK` import alias pattern * use `EncodeToString` for protocol string calculation and `String` for printing Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cc6209e8a0
commit
1c30414a6c
218 changed files with 2095 additions and 2521 deletions
|
@ -13,13 +13,8 @@ import (
|
|||
//
|
||||
// Returns error if container ID is nil.
|
||||
func Delete(c *Client, witness core.RemovalWitness) error {
|
||||
id := witness.ContainerID()
|
||||
if id == nil {
|
||||
return errNilArgument
|
||||
}
|
||||
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
id.Encode(binCnr)
|
||||
witness.ContainerID().Encode(binCnr)
|
||||
|
||||
var prm DeletePrm
|
||||
|
||||
|
@ -35,7 +30,7 @@ func Delete(c *Client, witness core.RemovalWitness) error {
|
|||
|
||||
// DeletePrm groups parameters of Delete client operation.
|
||||
type DeletePrm struct {
|
||||
cid []byte
|
||||
cnr []byte
|
||||
signature []byte
|
||||
token []byte
|
||||
|
||||
|
@ -44,7 +39,7 @@ type DeletePrm struct {
|
|||
|
||||
// SetCID sets container ID.
|
||||
func (d *DeletePrm) SetCID(cid []byte) {
|
||||
d.cid = cid
|
||||
d.cnr = cid
|
||||
}
|
||||
|
||||
// SetSignature sets signature.
|
||||
|
@ -71,7 +66,7 @@ func (c *Client) Delete(p DeletePrm) error {
|
|||
|
||||
prm := client.InvokePrm{}
|
||||
prm.SetMethod(deleteMethod)
|
||||
prm.SetArgs(p.cid, p.signature, p.token)
|
||||
prm.SetArgs(p.cnr, p.signature, p.token)
|
||||
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||
|
||||
err := c.client.Invoke(prm)
|
||||
|
|
|
@ -15,11 +15,7 @@ import (
|
|||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
// through Container contract call.
|
||||
func (c *Client) GetEACL(cnr *cid.ID) (*eacl.Table, error) {
|
||||
if cnr == nil {
|
||||
return nil, errNilArgument
|
||||
}
|
||||
|
||||
func (c *Client) GetEACL(cnr cid.ID) (*eacl.Table, error) {
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
cnr.Encode(binCnr)
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import (
|
|||
|
||||
type containerSource Client
|
||||
|
||||
func (x *containerSource) Get(cid *cid.ID) (*container.Container, error) {
|
||||
return Get((*Client)(x), cid)
|
||||
func (x *containerSource) Get(cnr cid.ID) (*container.Container, error) {
|
||||
return Get((*Client)(x), cnr)
|
||||
}
|
||||
|
||||
// AsContainerSource provides container Source interface
|
||||
|
@ -29,9 +29,7 @@ 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, cnr *cid.ID) (*container.Container, error) {
|
||||
func Get(c *Client, cnr cid.ID) (*container.Container, error) {
|
||||
binCnr := make([]byte, sha256.Size)
|
||||
cnr.Encode(binCnr)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
//
|
||||
// Returns the identifiers of all NeoFS containers if pointer
|
||||
// to user identifier is nil.
|
||||
func (c *Client) List(idUser *user.ID) ([]*cid.ID, error) {
|
||||
func (c *Client) List(idUser *user.ID) ([]cid.ID, error) {
|
||||
var rawID []byte
|
||||
|
||||
if idUser != nil {
|
||||
|
@ -37,21 +37,21 @@ func (c *Client) List(idUser *user.ID) ([]*cid.ID, error) {
|
|||
return nil, fmt.Errorf("could not get stack item array from stack item (%s): %w", listMethod, err)
|
||||
}
|
||||
|
||||
cidList := make([]*cid.ID, 0, len(res))
|
||||
cidList := make([]cid.ID, 0, len(res))
|
||||
for i := range res {
|
||||
rawCid, err := client.BytesFromStackItem(res[i])
|
||||
rawID, err := client.BytesFromStackItem(res[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", listMethod, err)
|
||||
}
|
||||
|
||||
var id cid.ID
|
||||
|
||||
err = id.Decode(rawCid)
|
||||
err = id.Decode(rawID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode container ID: %w", err)
|
||||
}
|
||||
|
||||
cidList = append(cidList, &id)
|
||||
cidList = append(cidList, id)
|
||||
}
|
||||
|
||||
return cidList, nil
|
||||
|
|
|
@ -99,7 +99,7 @@ type Estimation struct {
|
|||
|
||||
// Estimations is a structure of grouped container load estimation inside Container contract.
|
||||
type Estimations struct {
|
||||
ContainerID *cid.ID
|
||||
ContainerID cid.ID
|
||||
|
||||
Values []Estimation
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func (c *Client) GetUsedSpaceEstimations(id EstimationID) (*Estimations, error)
|
|||
return nil, fmt.Errorf("unexpected stack item count of estimations fields (%s)", getSizeMethod)
|
||||
}
|
||||
|
||||
rawCID, err := client.BytesFromStackItem(prms[0])
|
||||
rawCnr, err := client.BytesFromStackItem(prms[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get container ID byte array from stack item (%s): %w", getSizeMethod, err)
|
||||
}
|
||||
|
@ -137,15 +137,15 @@ func (c *Client) GetUsedSpaceEstimations(id EstimationID) (*Estimations, error)
|
|||
|
||||
var cnr cid.ID
|
||||
|
||||
err = cnr.Decode(rawCID)
|
||||
err = cnr.Decode(rawCnr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode container ID: %w", err)
|
||||
}
|
||||
|
||||
v2 := new(v2refs.ContainerID)
|
||||
v2.SetValue(rawCID)
|
||||
v2.SetValue(rawCnr)
|
||||
res := &Estimations{
|
||||
ContainerID: &cnr,
|
||||
ContainerID: cnr,
|
||||
Values: make([]Estimation, 0, len(prms)),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue