forked from TrueCloudLab/frostfs-node
[#174] Update to latest neofs-api-go changes
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
e98b77133c
commit
3de8febe57
47 changed files with 188 additions and 214 deletions
|
@ -86,15 +86,15 @@ func prettyPrintDecimal(decimal *accounting.Decimal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Println("value:", decimal.GetValue())
|
fmt.Println("value:", decimal.Value())
|
||||||
fmt.Println("precision:", decimal.GetPrecision())
|
fmt.Println("precision:", decimal.Precision())
|
||||||
} else {
|
} else {
|
||||||
// divider = 10^{precision}; v:365, p:2 => 365 / 10^2 = 3.65
|
// divider = 10^{precision}; v:365, p:2 => 365 / 10^2 = 3.65
|
||||||
divider := math.Pow(10, float64(decimal.GetPrecision()))
|
divider := math.Pow(10, float64(decimal.Precision()))
|
||||||
|
|
||||||
// %0.8f\n for precision 8
|
// %0.8f\n for precision 8
|
||||||
format := fmt.Sprintf("%%0.%df\n", decimal.GetPrecision())
|
format := fmt.Sprintf("%%0.%df\n", decimal.Precision())
|
||||||
|
|
||||||
fmt.Printf(format, float64(decimal.GetValue())/divider)
|
fmt.Printf(format, float64(decimal.Value())/divider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||||
v2ACL "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
|
||||||
grpcACL "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
|
||||||
v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
|
v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||||
grpccontainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
grpccontainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/policy"
|
"github.com/nspcc-dev/neofs-node/pkg/policy"
|
||||||
|
@ -139,7 +137,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
cnr := container.New()
|
cnr := container.New()
|
||||||
cnr.SetPlacementPolicy(placementPolicy.ToV2())
|
cnr.SetPlacementPolicy(placementPolicy)
|
||||||
cnr.SetBasicACL(basicACL)
|
cnr.SetBasicACL(basicACL)
|
||||||
cnr.SetAttributes(attributes)
|
cnr.SetAttributes(attributes)
|
||||||
cnr.SetNonce(nonce[:])
|
cnr.SetNonce(nonce[:])
|
||||||
|
@ -312,7 +310,7 @@ var getContainerInfoCmd = &cobra.Command{
|
||||||
)
|
)
|
||||||
|
|
||||||
if containerJSON {
|
if containerJSON {
|
||||||
data, err = v2container.ContainerToJSON(cnr.ToV2())
|
data, err = cnr.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't JSON encode container: %w", err)
|
return fmt.Errorf("can't JSON encode container: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -356,7 +354,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
v := eaclTable.Version()
|
v := eaclTable.Version()
|
||||||
if v.GetMajor() == 0 && v.GetMajor() == 0 {
|
if v.Major() == 0 && v.Major() == 0 {
|
||||||
fmt.Println("extended ACL table is not set for this container")
|
fmt.Println("extended ACL table is not set for this container")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -369,7 +367,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
var data []byte
|
var data []byte
|
||||||
|
|
||||||
if containerJSON {
|
if containerJSON {
|
||||||
data, err = v2ACL.TableToJSON(eaclTable.ToV2())
|
data, err = eaclTable.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't enode to JSON: %w", err)
|
return fmt.Errorf("can't enode to JSON: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -533,8 +531,8 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error)
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err = netmap.PlacementPolicyFromJSON([]byte(policyString))
|
result = netmap.NewPlacementPolicy()
|
||||||
if err == nil {
|
if err = result.UnmarshalJSON([]byte(policyString)); err == nil {
|
||||||
printVerbose("Parsed JSON encoded policy")
|
printVerbose("Parsed JSON encoded policy")
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -542,8 +540,8 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error)
|
||||||
return nil, errors.New("can't parse placement policy")
|
return nil, errors.New("can't parse placement policy")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAttributes(attributes []string) ([]*v2container.Attribute, error) {
|
func parseAttributes(attributes []string) ([]*container.Attribute, error) {
|
||||||
result := make([]*v2container.Attribute, 0, len(attributes)+2) // name + timestamp attributes
|
result := make([]*container.Attribute, 0, len(attributes)+2) // name + timestamp attributes
|
||||||
|
|
||||||
for i := range attributes {
|
for i := range attributes {
|
||||||
kvPair := strings.Split(attributes[i], attributeDelimiter)
|
kvPair := strings.Split(attributes[i], attributeDelimiter)
|
||||||
|
@ -551,7 +549,7 @@ func parseAttributes(attributes []string) ([]*v2container.Attribute, error) {
|
||||||
return nil, errors.New("invalid container attribute")
|
return nil, errors.New("invalid container attribute")
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedAttribute := new(v2container.Attribute)
|
parsedAttribute := container.NewAttribute()
|
||||||
parsedAttribute.SetKey(kvPair[0])
|
parsedAttribute.SetKey(kvPair[0])
|
||||||
parsedAttribute.SetValue(kvPair[1])
|
parsedAttribute.SetValue(kvPair[1])
|
||||||
|
|
||||||
|
@ -559,7 +557,7 @@ func parseAttributes(attributes []string) ([]*v2container.Attribute, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !containerNoTimestamp {
|
if !containerNoTimestamp {
|
||||||
timestamp := new(v2container.Attribute)
|
timestamp := container.NewAttribute()
|
||||||
timestamp.SetKey(container.AttributeTimestamp)
|
timestamp.SetKey(container.AttributeTimestamp)
|
||||||
timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10))
|
timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10))
|
||||||
|
|
||||||
|
@ -567,7 +565,7 @@ func parseAttributes(attributes []string) ([]*v2container.Attribute, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if containerName != "" {
|
if containerName != "" {
|
||||||
cnrName := new(v2container.Attribute)
|
cnrName := container.NewAttribute()
|
||||||
cnrName.SetKey(container.AttributeName)
|
cnrName.SetKey(container.AttributeName)
|
||||||
cnrName.SetValue(containerName)
|
cnrName.SetValue(containerName)
|
||||||
|
|
||||||
|
@ -629,7 +627,7 @@ func prettyPrintContainer(cnr *container.Container, jsonEncoding bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if jsonEncoding {
|
if jsonEncoding {
|
||||||
data, err := v2container.ContainerToJSON(cnr.ToV2())
|
data, err := cnr.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printVerbose("Can't convert container to json: %w", err)
|
printVerbose("Can't convert container to json: %w", err)
|
||||||
return
|
return
|
||||||
|
@ -647,14 +645,12 @@ func prettyPrintContainer(cnr *container.Container, jsonEncoding bool) {
|
||||||
id := container.CalculateID(cnr)
|
id := container.CalculateID(cnr)
|
||||||
fmt.Println("container ID:", id)
|
fmt.Println("container ID:", id)
|
||||||
|
|
||||||
version := cnr.GetVersion()
|
version := cnr.Version()
|
||||||
fmt.Printf("version: %d.%d\n", version.GetMajor(), version.GetMinor())
|
fmt.Printf("version: %d.%d\n", version.Major(), version.Minor())
|
||||||
|
|
||||||
// todo: return pkg structures instead of v2 structures
|
fmt.Println("owner ID:", cnr.OwnerID())
|
||||||
ownerID := owner.NewIDFromV2(cnr.GetOwnerID())
|
|
||||||
fmt.Println("owner ID:", ownerID)
|
|
||||||
|
|
||||||
basicACL := cnr.GetBasicACL()
|
basicACL := cnr.BasicACL()
|
||||||
fmt.Printf("basic ACL: %s", strconv.FormatUint(uint64(basicACL), 16))
|
fmt.Printf("basic ACL: %s", strconv.FormatUint(uint64(basicACL), 16))
|
||||||
switch basicACL {
|
switch basicACL {
|
||||||
case acl.PublicBasicRule:
|
case acl.PublicBasicRule:
|
||||||
|
@ -667,27 +663,26 @@ func prettyPrintContainer(cnr *container.Container, jsonEncoding bool) {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, attribute := range cnr.GetAttributes() {
|
for _, attribute := range cnr.Attributes() {
|
||||||
if attribute.GetKey() == container.AttributeTimestamp {
|
if attribute.Key() == container.AttributeTimestamp {
|
||||||
fmt.Printf("attribute: %s=%s (%s)\n",
|
fmt.Printf("attribute: %s=%s (%s)\n",
|
||||||
attribute.GetKey(),
|
attribute.Key(),
|
||||||
attribute.GetValue(),
|
attribute.Value(),
|
||||||
prettyPrintUnixTime(attribute.GetValue()))
|
prettyPrintUnixTime(attribute.Value()))
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("attribute: %s=%s\n", attribute.GetKey(), attribute.GetValue())
|
fmt.Printf("attribute: %s=%s\n", attribute.Key(), attribute.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, err := uuid.FromBytes(cnr.GetNonce())
|
nonce, err := uuid.FromBytes(cnr.Nonce())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Println("nonce:", nonce)
|
fmt.Println("nonce:", nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("placement policy:")
|
fmt.Println("placement policy:")
|
||||||
cnrPolicy := netmap.NewPlacementPolicyFromV2(cnr.GetPlacementPolicy())
|
fmt.Println(strings.Join(policy.Encode(cnr.PlacementPolicy()), "\n"))
|
||||||
fmt.Println(strings.Join(policy.Encode(cnrPolicy), "\n"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEACL(eaclPath string) (*eacl.Table, error) {
|
func parseEACL(eaclPath string) (*eacl.Table, error) {
|
||||||
|
@ -703,23 +698,17 @@ func parseEACL(eaclPath string) (*eacl.Table, error) {
|
||||||
return nil, fmt.Errorf("can't read file with EACL: %w", err)
|
return nil, fmt.Errorf("can't read file with EACL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := new(grpcACL.EACLTable)
|
table := eacl.NewTable()
|
||||||
if proto.Unmarshal(data, msg) == nil {
|
if err = table.UnmarshalJSON(data); err == nil {
|
||||||
printVerbose("Parsed binary encoded EACL table")
|
|
||||||
v2 := v2ACL.TableFromGRPCMessage(msg)
|
|
||||||
return eacl.NewTableFromV2(v2), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if v2, err := v2ACL.TableFromJSON(data); err == nil {
|
|
||||||
printVerbose("Parsed JSON encoded EACL table")
|
printVerbose("Parsed JSON encoded EACL table")
|
||||||
return eacl.NewTableFromV2(v2), nil
|
return table, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("can't parse EACL table: %w", err)
|
return nil, fmt.Errorf("can't parse EACL table: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prettyPrintEACL(table *eacl.Table) {
|
func prettyPrintEACL(table *eacl.Table) {
|
||||||
data, err := v2ACL.TableToJSON(table.ToV2())
|
data, err := table.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printVerbose("Can't convert container to json: %w", err)
|
printVerbose("Can't convert container to json: %w", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -81,7 +81,7 @@ var localNodeInfoCmd = &cobra.Command{
|
||||||
|
|
||||||
func prettyPrintNodeInfo(i *netmap.NodeInfo, jsonEncoding bool) {
|
func prettyPrintNodeInfo(i *netmap.NodeInfo, jsonEncoding bool) {
|
||||||
if jsonEncoding {
|
if jsonEncoding {
|
||||||
data, err := netmap.NodeInfoToJSON(i)
|
data, err := i.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printVerbose("Can't convert container to json: %w", err)
|
printVerbose("Can't convert container to json: %w", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -20,10 +20,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
v2ACL "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
|
||||||
grpcACL "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -236,7 +233,7 @@ func deleteObject(cmd *cobra.Command, _ []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Object removed successfully.")
|
cmd.Println("Object removed successfully.")
|
||||||
cmd.Printf(" ID: %s\n CID: %s\n", objAddr.GetObjectID(), objAddr.GetContainerID())
|
cmd.Printf(" ID: %s\n CID: %s\n", objAddr.ObjectID(), objAddr.ContainerID())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,9 +387,9 @@ func getObjectHash(cmd *cobra.Command, _ []string) error {
|
||||||
}
|
}
|
||||||
switch typ {
|
switch typ {
|
||||||
case hashSha256:
|
case hashSha256:
|
||||||
cmd.Println(hex.EncodeToString(obj.GetPayloadChecksum().GetSum()))
|
cmd.Println(hex.EncodeToString(obj.PayloadChecksum().Sum()))
|
||||||
case hashTz:
|
case hashTz:
|
||||||
cmd.Println(hex.EncodeToString(obj.GetPayloadHomomorphicHash().GetSum()))
|
cmd.Println(hex.EncodeToString(obj.PayloadHomomorphicHash().Sum()))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -592,14 +589,14 @@ func printHeader(cmd *cobra.Command, obj *object.Object, filename string) error
|
||||||
cmd.Printf("[%s] Header successfully saved.", filename)
|
cmd.Printf("[%s] Header successfully saved.", filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("ID: %s\n", obj.GetID())
|
cmd.Printf("ID: %s\n", obj.ID())
|
||||||
cmd.Printf("CID: %s\n", obj.GetContainerID())
|
cmd.Printf("CID: %s\n", obj.ContainerID())
|
||||||
cmd.Printf("Owner: %s\n", obj.GetOwnerID())
|
cmd.Printf("Owner: %s\n", obj.OwnerID())
|
||||||
cmd.Printf("CreatedAt: %d\n", obj.GetCreationEpoch())
|
cmd.Printf("CreatedAt: %d\n", obj.CreationEpoch())
|
||||||
cmd.Printf("Size: %d\n", obj.GetPayloadSize())
|
cmd.Printf("Size: %d\n", obj.PayloadSize())
|
||||||
cmd.Printf("HomoHash: %s\n", hex.EncodeToString(obj.GetPayloadHomomorphicHash().GetSum()))
|
cmd.Printf("HomoHash: %s\n", hex.EncodeToString(obj.PayloadHomomorphicHash().Sum()))
|
||||||
cmd.Printf("Checksum: %s\n", hex.EncodeToString(obj.GetPayloadChecksum().GetSum()))
|
cmd.Printf("Checksum: %s\n", hex.EncodeToString(obj.PayloadChecksum().Sum()))
|
||||||
switch obj.GetType() {
|
switch obj.Type() {
|
||||||
case object.TypeRegular:
|
case object.TypeRegular:
|
||||||
cmd.Println("Type: regular")
|
cmd.Println("Type: regular")
|
||||||
case object.TypeTombstone:
|
case object.TypeTombstone:
|
||||||
|
@ -611,15 +608,15 @@ func printHeader(cmd *cobra.Command, obj *object.Object, filename string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Attributes:")
|
cmd.Println("Attributes:")
|
||||||
for _, attr := range obj.GetAttributes() {
|
for _, attr := range obj.Attributes() {
|
||||||
if attr.GetKey() == object.AttributeTimestamp {
|
if attr.Key() == object.AttributeTimestamp {
|
||||||
cmd.Printf(" %s=%s (%s)\n",
|
cmd.Printf(" %s=%s (%s)\n",
|
||||||
attr.GetKey(),
|
attr.Key(),
|
||||||
attr.GetValue(),
|
attr.Value(),
|
||||||
prettyPrintUnixTime(attr.GetValue()))
|
prettyPrintUnixTime(attr.Value()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cmd.Printf(" %s=%s\n", attr.GetKey(), attr.GetValue())
|
cmd.Printf(" %s=%s\n", attr.Key(), attr.Value())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -650,19 +647,16 @@ func getBearerToken(cmd *cobra.Command, flagname string) (*token.BearerToken, er
|
||||||
return nil, fmt.Errorf("can't read bearer token file: %w", err)
|
return nil, fmt.Errorf("can't read bearer token file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
v2token, err := v2ACL.BearerTokenFromJSON(data)
|
tok := token.NewBearerToken()
|
||||||
if err != nil {
|
if err := tok.UnmarshalJSON(data); err != nil {
|
||||||
msg := new(grpcACL.BearerToken)
|
if err = tok.Unmarshal(data); err != nil {
|
||||||
if proto.Unmarshal(data, msg) != nil {
|
return nil, fmt.Errorf("can't decode bearer token: %w", err)
|
||||||
return nil, fmt.Errorf("can't decode beare token: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v2token = v2ACL.BearerTokenFromGRPCMessage(msg)
|
|
||||||
|
|
||||||
printVerbose("Using binary encoded bearer token")
|
printVerbose("Using binary encoded bearer token")
|
||||||
} else {
|
} else {
|
||||||
printVerbose("Using JSON encoded bearer token")
|
printVerbose("Using JSON encoded bearer token")
|
||||||
}
|
}
|
||||||
|
|
||||||
return token.NewBearerTokenFromV2(v2token), nil
|
return tok, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ 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/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
v2ACL "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
|
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -108,7 +107,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
if jsonFlag || len(to) == 0 {
|
if jsonFlag || len(to) == 0 {
|
||||||
data, err = v2ACL.BearerTokenToJSON(btok.ToV2())
|
data, err = btok.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't JSON encode bearer token: %w", err)
|
return fmt.Errorf("can't JSON encode bearer token: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -147,7 +146,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
if jsonFlag || len(to) == 0 {
|
if jsonFlag || len(to) == 0 {
|
||||||
data, err = v2ACL.TableToJSON(table.ToV2())
|
data, err = table.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't JSON encode extended ACL table: %w", err)
|
return fmt.Errorf("can't JSON encode extended ACL table: %w", err)
|
||||||
}
|
}
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -14,7 +14,7 @@ require (
|
||||||
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
|
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
|
||||||
github.com/multiformats/go-multihash v0.0.13 // indirect
|
github.com/multiformats/go-multihash v0.0.13 // indirect
|
||||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b
|
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b
|
||||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201111110701-789474906015
|
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201116094437-fe336fd5ba28
|
||||||
github.com/nspcc-dev/neofs-crypto v0.3.0
|
github.com/nspcc-dev/neofs-crypto v0.3.0
|
||||||
github.com/nspcc-dev/tzhash v1.4.0
|
github.com/nspcc-dev/tzhash v1.4.0
|
||||||
github.com/panjf2000/ants/v2 v2.3.0
|
github.com/panjf2000/ants/v2 v2.3.0
|
||||||
|
@ -36,7 +36,6 @@ require (
|
||||||
golang.org/x/sys v0.0.0-20201024232916-9f70ab9862d5 // indirect
|
golang.org/x/sys v0.0.0-20201024232916-9f70ab9862d5 // indirect
|
||||||
golang.org/x/tools v0.0.0-20200123022218-593de606220b // indirect
|
golang.org/x/tools v0.0.0-20200123022218-593de606220b // indirect
|
||||||
google.golang.org/grpc v1.29.1
|
google.golang.org/grpc v1.29.1
|
||||||
google.golang.org/protobuf v1.23.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Used for debug reasons
|
// Used for debug reasons
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -10,24 +10,24 @@ import (
|
||||||
|
|
||||||
var errNilPolicy = errors.New("placement policy is nil")
|
var errNilPolicy = errors.New("placement policy is nil")
|
||||||
|
|
||||||
// CheckFormat conducts an initial check of the container data.
|
// CheckFormat conducts an initial check of the v2 container data.
|
||||||
//
|
//
|
||||||
// It is expected that if a container fails this test,
|
// It is expected that if a container fails this test,
|
||||||
// it will not be inner-ring approved.
|
// it will not be inner-ring approved.
|
||||||
func CheckFormat(c *container.Container) error {
|
func CheckFormat(c *container.Container) error {
|
||||||
if c.GetPlacementPolicy() == nil {
|
if c.PlacementPolicy() == nil {
|
||||||
return errNilPolicy
|
return errNilPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pkg.IsSupportedVersion(pkg.NewVersionFromV2(c.GetVersion())); err != nil {
|
if err := pkg.IsSupportedVersion(c.Version()); err != nil {
|
||||||
return errors.Wrap(err, "incorrect version")
|
return errors.Wrap(err, "incorrect version")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(c.GetOwnerID().GetValue()) != owner.NEO3WalletSize {
|
if len(c.OwnerID().ToV2().GetValue()) != owner.NEO3WalletSize {
|
||||||
return errors.Wrap(owner.ErrBadID, "incorrect owner identifier")
|
return errors.Wrap(owner.ErrBadID, "incorrect owner identifier")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := uuid.FromBytes(c.GetNonce()); err != nil {
|
if _, err := uuid.FromBytes(c.Nonce()); err != nil {
|
||||||
return errors.Wrap(err, "incorrect nonce")
|
return errors.Wrap(err, "incorrect nonce")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,19 @@ func TestCheckFormat(t *testing.T) {
|
||||||
|
|
||||||
require.Error(t, CheckFormat(c))
|
require.Error(t, CheckFormat(c))
|
||||||
|
|
||||||
policy := new(netmap.PlacementPolicy)
|
policy := netmap.NewPlacementPolicy()
|
||||||
c.SetPlacementPolicy(policy.ToV2())
|
c.SetPlacementPolicy(policy)
|
||||||
|
|
||||||
require.Error(t, CheckFormat(c))
|
require.Error(t, CheckFormat(c))
|
||||||
|
|
||||||
c.SetVersion(pkg.SDKVersion().ToV2())
|
c.SetVersion(pkg.SDKVersion())
|
||||||
|
|
||||||
require.Error(t, CheckFormat(c))
|
require.Error(t, CheckFormat(c))
|
||||||
|
|
||||||
wallet, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
|
wallet, err := owner.NEO3WalletFromPublicKey(&test.DecodeKey(-1).PublicKey)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.SetOwnerID(owner.NewIDFromNeo3Wallet(wallet).ToV2())
|
c.SetOwnerID(owner.NewIDFromNeo3Wallet(wallet))
|
||||||
|
|
||||||
c.SetNonce(nil)
|
c.SetNonce(nil)
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,9 @@ func NewFormatValidator(opts ...FormatValidatorOption) *FormatValidator {
|
||||||
func (v *FormatValidator) Validate(obj *Object) error {
|
func (v *FormatValidator) Validate(obj *Object) error {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return errNilObject
|
return errNilObject
|
||||||
} else if obj.GetID() == nil {
|
} else if obj.ID() == nil {
|
||||||
return errNilID
|
return errNilID
|
||||||
} else if obj.GetContainerID() == nil {
|
} else if obj.ContainerID() == nil {
|
||||||
return errNilCID
|
return errNilCID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,11 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *FormatValidator) validateSignatureKey(obj *Object) error {
|
func (v *FormatValidator) validateSignatureKey(obj *Object) error {
|
||||||
token := obj.GetSessionToken()
|
token := obj.SessionToken()
|
||||||
key := obj.GetSignature().GetKey()
|
key := obj.Signature().Key()
|
||||||
|
|
||||||
if token == nil || !bytes.Equal(token.SessionKey(), key) {
|
if token == nil || !bytes.Equal(token.SessionKey(), key) {
|
||||||
return v.checkOwnerKey(obj.GetOwnerID(), obj.GetSignature().GetKey())
|
return v.checkOwnerKey(obj.OwnerID(), obj.Signature().Key())
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: perform token verification
|
// FIXME: perform token verification
|
||||||
|
@ -123,7 +123,7 @@ func (v *FormatValidator) ValidateContent(t object.Type, payload []byte) error {
|
||||||
addrList := content.GetAddressList()
|
addrList := content.GetAddressList()
|
||||||
|
|
||||||
for _, addr := range addrList {
|
for _, addr := range addrList {
|
||||||
if addr.GetContainerID() == nil || addr.GetObjectID() == nil {
|
if addr.ContainerID() == nil || addr.ObjectID() == nil {
|
||||||
return errors.Errorf("(%T) empty address reference in tombstone", v)
|
return errors.Errorf("(%T) empty address reference in tombstone", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ type Object struct {
|
||||||
func (o *Object) Address() *object.Address {
|
func (o *Object) Address() *object.Address {
|
||||||
if o != nil {
|
if o != nil {
|
||||||
aV2 := new(refs.Address)
|
aV2 := new(refs.Address)
|
||||||
aV2.SetObjectID(o.GetID().ToV2())
|
aV2.SetObjectID(o.ID().ToV2())
|
||||||
aV2.SetContainerID(o.GetContainerID().ToV2())
|
aV2.SetContainerID(o.ContainerID().ToV2())
|
||||||
|
|
||||||
return object.NewAddressFromV2(aV2)
|
return object.NewAddressFromV2(aV2)
|
||||||
}
|
}
|
||||||
|
@ -56,22 +56,10 @@ func New() *Object {
|
||||||
return NewFromSDK(object.New())
|
return NewFromSDK(object.New())
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromBytes restores Object from binary format.
|
|
||||||
func FromBytes(data []byte) (*Object, error) {
|
|
||||||
o, err := object.FromBytes(data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Object{
|
|
||||||
Object: o,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetParent returns parent object.
|
// GetParent returns parent object.
|
||||||
func (o *Object) GetParent() *Object {
|
func (o *Object) GetParent() *Object {
|
||||||
if o != nil {
|
if o != nil {
|
||||||
if par := o.Object.GetParent(); par != nil {
|
if par := o.Object.Parent(); par != nil {
|
||||||
return &Object{
|
return &Object{
|
||||||
Object: par,
|
Object: par,
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (c *TombstoneContentV2) StableUnmarshal(data []byte) error {
|
||||||
data = data[ln:]
|
data = data[ln:]
|
||||||
|
|
||||||
addr := new(refs.Address)
|
addr := new(refs.Address)
|
||||||
if err := addr.StableUnmarshal(data[:sz]); err != nil {
|
if err := addr.Unmarshal(data[:sz]); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,9 @@ func (s *Storage) Get(addr *objectSDK.Address) (*object.Object, error) {
|
||||||
return nil, errors.Wrap(err, "could not get object from BLOB storage")
|
return nil, errors.Wrap(err, "could not get object from BLOB storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
return object.FromBytes(objBytes)
|
obj := object.New()
|
||||||
|
|
||||||
|
return obj, obj.Unmarshal(objBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) Head(addr *objectSDK.Address) (*object.Object, error) {
|
func (s *Storage) Head(addr *objectSDK.Address) (*object.Object, error) {
|
||||||
|
|
|
@ -128,7 +128,7 @@ func TestDB_Delete(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
fs := objectSDK.SearchFilters{}
|
fs := objectSDK.SearchFilters{}
|
||||||
fs.AddObjectContainerIDFilter(objectSDK.MatchStringEqual, o.GetContainerID())
|
fs.AddObjectContainerIDFilter(objectSDK.MatchStringEqual, o.ContainerID())
|
||||||
|
|
||||||
testSelect(t, db, fs, o.Address())
|
testSelect(t, db, fs, o.Address())
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ func (db *DB) Get(addr *objectSDK.Address) (*object.Object, error) {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
obj, err = object.FromBytes(data)
|
obj = object.New()
|
||||||
|
|
||||||
|
err = obj.Unmarshal(data)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -94,27 +94,27 @@ func addressKey(addr *objectSDK.Address) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func objectIndices(obj *object.Object, parent bool) []bucketItem {
|
func objectIndices(obj *object.Object, parent bool) []bucketItem {
|
||||||
as := obj.GetAttributes()
|
as := obj.Attributes()
|
||||||
|
|
||||||
res := make([]bucketItem, 0, 7+len(as)) // 7 predefined buckets and object attributes
|
res := make([]bucketItem, 0, 7+len(as)) // 7 predefined buckets and object attributes
|
||||||
|
|
||||||
childfreeVal := v2object.BooleanPropertyValueTrue
|
childfreeVal := v2object.BooleanPropertyValueTrue
|
||||||
if len(obj.GetChildren()) > 0 {
|
if len(obj.Children()) > 0 {
|
||||||
childfreeVal = ""
|
childfreeVal = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
res = append(res,
|
res = append(res,
|
||||||
bucketItem{
|
bucketItem{
|
||||||
key: v2object.FilterHeaderVersion,
|
key: v2object.FilterHeaderVersion,
|
||||||
val: obj.GetVersion().String(),
|
val: obj.Version().String(),
|
||||||
},
|
},
|
||||||
bucketItem{
|
bucketItem{
|
||||||
key: v2object.FilterHeaderContainerID,
|
key: v2object.FilterHeaderContainerID,
|
||||||
val: obj.GetContainerID().String(),
|
val: obj.ContainerID().String(),
|
||||||
},
|
},
|
||||||
bucketItem{
|
bucketItem{
|
||||||
key: v2object.FilterHeaderOwnerID,
|
key: v2object.FilterHeaderOwnerID,
|
||||||
val: obj.GetOwnerID().String(),
|
val: obj.OwnerID().String(),
|
||||||
},
|
},
|
||||||
bucketItem{
|
bucketItem{
|
||||||
key: v2object.FilterPropertyChildfree,
|
key: v2object.FilterPropertyChildfree,
|
||||||
|
@ -122,12 +122,12 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem {
|
||||||
},
|
},
|
||||||
bucketItem{
|
bucketItem{
|
||||||
key: v2object.FilterHeaderParent,
|
key: v2object.FilterHeaderParent,
|
||||||
val: obj.GetParentID().String(),
|
val: obj.ParentID().String(),
|
||||||
},
|
},
|
||||||
// TODO: add remaining fields after neofs-api#72
|
// TODO: add remaining fields after neofs-api#72
|
||||||
)
|
)
|
||||||
|
|
||||||
if obj.GetType() == objectSDK.TypeRegular && !obj.HasParent() {
|
if obj.Type() == objectSDK.TypeRegular && !obj.HasParent() {
|
||||||
res = append(res, bucketItem{
|
res = append(res, bucketItem{
|
||||||
key: v2object.FilterPropertyRoot,
|
key: v2object.FilterPropertyRoot,
|
||||||
})
|
})
|
||||||
|
@ -141,8 +141,8 @@ func objectIndices(obj *object.Object, parent bool) []bucketItem {
|
||||||
|
|
||||||
for _, a := range as {
|
for _, a := range as {
|
||||||
res = append(res, bucketItem{
|
res = append(res, bucketItem{
|
||||||
key: a.GetKey(),
|
key: a.Key(),
|
||||||
val: a.GetValue(),
|
val: a.Value(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,15 +100,15 @@ func TestMismatchAfterMatch(t *testing.T) {
|
||||||
|
|
||||||
require.NoError(t, db.Put(obj))
|
require.NoError(t, db.Put(obj))
|
||||||
|
|
||||||
a := obj.GetAttributes()[0]
|
a := obj.Attributes()[0]
|
||||||
|
|
||||||
fs := objectSDK.SearchFilters{}
|
fs := objectSDK.SearchFilters{}
|
||||||
|
|
||||||
// 1st - mismatching filter
|
// 1st - mismatching filter
|
||||||
fs.AddFilter(a.GetKey(), a.GetValue()+"1", objectSDK.MatchStringEqual)
|
fs.AddFilter(a.Key(), a.Value()+"1", objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
// 2nd - matching filter
|
// 2nd - matching filter
|
||||||
fs.AddFilter(a.GetKey(), a.GetValue(), objectSDK.MatchStringEqual)
|
fs.AddFilter(a.Key(), a.Value(), objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
testSelect(t, db, fs)
|
testSelect(t, db, fs)
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func addCommonAttribute(objs ...*object.Object) *objectSDK.Attribute {
|
||||||
|
|
||||||
for _, o := range objs {
|
for _, o := range objs {
|
||||||
object.NewRawFromObject(o).SetAttributes(
|
object.NewRawFromObject(o).SetAttributes(
|
||||||
append(o.GetAttributes(), aCommon)...,
|
append(o.Attributes(), aCommon)...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func TestSelectRemoved(t *testing.T) {
|
||||||
require.NoError(t, db.Put(obj2))
|
require.NoError(t, db.Put(obj2))
|
||||||
|
|
||||||
fs := objectSDK.SearchFilters{}
|
fs := objectSDK.SearchFilters{}
|
||||||
fs.AddFilter(a.GetKey(), a.GetValue(), objectSDK.MatchStringEqual)
|
fs.AddFilter(a.Key(), a.Value(), objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
testSelect(t, db, fs, obj1.Address(), obj2.Address())
|
testSelect(t, db, fs, obj1.Address(), obj2.Address())
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ func TestMissingObjectAttribute(t *testing.T) {
|
||||||
// add object w/o attribute
|
// add object w/o attribute
|
||||||
obj2 := generateObject(t, testPrm{})
|
obj2 := generateObject(t, testPrm{})
|
||||||
|
|
||||||
a1 := obj1.GetAttributes()[0]
|
a1 := obj1.Attributes()[0]
|
||||||
|
|
||||||
// add common attribute
|
// add common attribute
|
||||||
aCommon := addCommonAttribute(obj1, obj2)
|
aCommon := addCommonAttribute(obj1, obj2)
|
||||||
|
@ -177,10 +177,10 @@ func TestMissingObjectAttribute(t *testing.T) {
|
||||||
fs := objectSDK.SearchFilters{}
|
fs := objectSDK.SearchFilters{}
|
||||||
|
|
||||||
// 1st filter by common attribute
|
// 1st filter by common attribute
|
||||||
fs.AddFilter(aCommon.GetKey(), aCommon.GetValue(), objectSDK.MatchStringEqual)
|
fs.AddFilter(aCommon.Key(), aCommon.Value(), objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
// next filter by attribute from 1st object only
|
// next filter by attribute from 1st object only
|
||||||
fs.AddFilter(a1.GetKey(), a1.GetValue(), objectSDK.MatchStringEqual)
|
fs.AddFilter(a1.Key(), a1.Value(), objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
testSelect(t, db, fs, obj1.Address())
|
testSelect(t, db, fs, obj1.Address())
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ func (b Service) findRequestInfo(
|
||||||
|
|
||||||
// fetch actual container
|
// fetch actual container
|
||||||
cnr, err := b.containers.Get(cid)
|
cnr, err := b.containers.Get(cid)
|
||||||
if err != nil || cnr.GetOwnerID() == nil {
|
if err != nil || cnr.OwnerID() == nil {
|
||||||
return info, ErrUnknownContainer
|
return info, ErrUnknownContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,10 +417,10 @@ func (b Service) findRequestInfo(
|
||||||
verb := sourceVerbOfRequest(req, op)
|
verb := sourceVerbOfRequest(req, op)
|
||||||
// todo: check verb sanity, if it was generated correctly. Do we need it ?
|
// todo: check verb sanity, if it was generated correctly. Do we need it ?
|
||||||
|
|
||||||
info.basicACL = basicACLHelper(cnr.GetBasicACL())
|
info.basicACL = basicACLHelper(cnr.BasicACL())
|
||||||
info.requestRole = role
|
info.requestRole = role
|
||||||
info.operation = verb
|
info.operation = verb
|
||||||
info.owner = owner.NewIDFromV2(cnr.GetOwnerID())
|
info.owner = cnr.OwnerID()
|
||||||
info.cid = cid
|
info.cid = cid
|
||||||
|
|
||||||
// it is assumed that at the moment the key will be valid,
|
// it is assumed that at the moment the key will be valid,
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (c SenderClassifier) Classify(
|
||||||
// todo: get owner from neofs.id if present
|
// todo: get owner from neofs.id if present
|
||||||
|
|
||||||
// if request owner is the same as container owner, return RoleUser
|
// if request owner is the same as container owner, return RoleUser
|
||||||
if bytes.Equal(cnr.GetOwnerID().GetValue(), ownerID.ToV2().GetValue()) {
|
if bytes.Equal(cnr.OwnerID().ToV2().GetValue(), ownerID.ToV2().GetValue()) {
|
||||||
return acl.RoleUser, ownerKeyInBytes, nil
|
return acl.RoleUser, ownerKeyInBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ func requestOwner(req metaWithToken) (*owner.ID, *ecdsa.PublicKey, error) {
|
||||||
return nil, nil, errors.Wrap(ErrMalformedRequest, "nil at body signature")
|
return nil, nil, errors.Wrap(ErrMalformedRequest, "nil at body signature")
|
||||||
}
|
}
|
||||||
|
|
||||||
key := crypto.UnmarshalPublicKey(bodySignature.GetKey())
|
key := crypto.UnmarshalPublicKey(bodySignature.Key())
|
||||||
neo3wallet, err := owner.NEO3WalletFromPublicKey(key)
|
neo3wallet, err := owner.NEO3WalletFromPublicKey(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "can't create neo3 wallet")
|
return nil, nil, errors.Wrap(err, "can't create neo3 wallet")
|
||||||
|
@ -174,7 +174,7 @@ func lookupKeyInContainer(
|
||||||
owner, cid []byte,
|
owner, cid []byte,
|
||||||
cnr *container.Container) (bool, error) {
|
cnr *container.Container) (bool, error) {
|
||||||
|
|
||||||
cnrNodes, err := nm.GetContainerNodes(netmap.NewPlacementPolicyFromV2(cnr.GetPlacementPolicy()), cid)
|
cnrNodes, err := nm.GetContainerNodes(cnr.PlacementPolicy(), cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ type Storage interface {
|
||||||
|
|
||||||
// Header is an interface of string key-value header.
|
// Header is an interface of string key-value header.
|
||||||
type Header interface {
|
type Header interface {
|
||||||
GetKey() string
|
Key() string
|
||||||
GetValue() string
|
Value() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypedHeaderSource is the interface that wraps
|
// TypedHeaderSource is the interface that wraps
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (s *testEACLStorage) GetEACL(id *container.ID) (*eacl.Table, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testLocalStorage) Head(addr *objectSDK.Address) (*object.Object, error) {
|
func (s *testLocalStorage) Head(addr *objectSDK.Address) (*object.Object, error) {
|
||||||
require.True(s.t, addr.GetContainerID().Equal(addr.GetContainerID()) && addr.GetObjectID().Equal(addr.GetObjectID()))
|
require.True(s.t, addr.ContainerID().Equal(addr.ContainerID()) && addr.ObjectID().Equal(addr.ObjectID()))
|
||||||
|
|
||||||
return s.obj, nil
|
return s.obj, nil
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ func TestHeadRequest(t *testing.T) {
|
||||||
obj: obj.Object(),
|
obj: obj.Object(),
|
||||||
}
|
}
|
||||||
|
|
||||||
cid := addr.GetContainerID()
|
cid := addr.ContainerID()
|
||||||
unit := new(eacl2.ValidationUnit).
|
unit := new(eacl2.ValidationUnit).
|
||||||
WithContainerID(cid).
|
WithContainerID(cid).
|
||||||
WithOperation(eacl.OperationHead).
|
WithOperation(eacl.OperationHead).
|
||||||
|
|
|
@ -3,6 +3,7 @@ package v2
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||||
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
|
@ -71,7 +72,7 @@ func requestHeaders(msg xHeaderSource) []eacl.Header {
|
||||||
res := make([]eacl.Header, 0, len(xHdrs))
|
res := make([]eacl.Header, 0, len(xHdrs))
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
res = append(res, xHdrs[i])
|
res = append(res, pkg.NewXHeaderFromV2(xHdrs[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -15,11 +15,11 @@ type sysObjHdr struct {
|
||||||
k, v string
|
k, v string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sysObjHdr) GetKey() string {
|
func (s *sysObjHdr) Key() string {
|
||||||
return s.k
|
return s.k
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sysObjHdr) GetValue() string {
|
func (s *sysObjHdr) Value() string {
|
||||||
return s.v
|
return s.v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,27 +48,27 @@ func headersFromObject(obj *object.Object) []eacl.Header {
|
||||||
// container ID
|
// container ID
|
||||||
&sysObjHdr{
|
&sysObjHdr{
|
||||||
k: acl.FilterObjectContainerID,
|
k: acl.FilterObjectContainerID,
|
||||||
v: cidValue(obj.GetContainerID()),
|
v: cidValue(obj.ContainerID()),
|
||||||
},
|
},
|
||||||
// owner ID
|
// owner ID
|
||||||
&sysObjHdr{
|
&sysObjHdr{
|
||||||
k: acl.FilterObjectOwnerID,
|
k: acl.FilterObjectOwnerID,
|
||||||
v: ownerIDValue(obj.GetOwnerID()),
|
v: ownerIDValue(obj.OwnerID()),
|
||||||
},
|
},
|
||||||
// creation epoch
|
// creation epoch
|
||||||
&sysObjHdr{
|
&sysObjHdr{
|
||||||
k: acl.FilterObjectCreationEpoch,
|
k: acl.FilterObjectCreationEpoch,
|
||||||
v: u64Value(obj.GetCreationEpoch()),
|
v: u64Value(obj.CreationEpoch()),
|
||||||
},
|
},
|
||||||
// payload size
|
// payload size
|
||||||
&sysObjHdr{
|
&sysObjHdr{
|
||||||
k: acl.FilterObjectPayloadLength,
|
k: acl.FilterObjectPayloadLength,
|
||||||
v: u64Value(obj.GetPayloadSize()),
|
v: u64Value(obj.PayloadSize()),
|
||||||
},
|
},
|
||||||
// TODO: add others fields after neofs-api#84
|
// TODO: add others fields after neofs-api#84
|
||||||
)
|
)
|
||||||
|
|
||||||
attrs := obj.GetAttributes()
|
attrs := obj.Attributes()
|
||||||
hs := make([]eacl.Header, 0, len(attrs))
|
hs := make([]eacl.Header, 0, len(attrs))
|
||||||
|
|
||||||
for i := range attrs {
|
for i := range attrs {
|
||||||
|
|
|
@ -124,7 +124,7 @@ func matchFilters(hdrSrc TypedHeaderSource, filters []eacl.Filter) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check header name
|
// check header name
|
||||||
if header.GetKey() != filter.Key() {
|
if header.Key() != filter.Key() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,10 +172,10 @@ func targetMatches(unit *ValidationUnit, record eacl.Record) bool {
|
||||||
// Maps match type to corresponding function.
|
// Maps match type to corresponding function.
|
||||||
var mMatchFns = map[eacl.Match]func(Header, eacl.Filter) bool{
|
var mMatchFns = map[eacl.Match]func(Header, eacl.Filter) bool{
|
||||||
eacl.MatchStringEqual: func(header Header, filter eacl.Filter) bool {
|
eacl.MatchStringEqual: func(header Header, filter eacl.Filter) bool {
|
||||||
return header.GetValue() == filter.Value()
|
return header.Value() == filter.Value()
|
||||||
},
|
},
|
||||||
|
|
||||||
eacl.MatchStringNotEqual: func(header Header, filter eacl.Filter) bool {
|
eacl.MatchStringNotEqual: func(header Header, filter eacl.Filter) bool {
|
||||||
return header.GetValue() != filter.Value()
|
return header.Value() != filter.Value()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ func (s *Service) Delete(ctx context.Context, prm *Prm) (*Response, error) {
|
||||||
// content address storage (CAS) and one tombstone for several split
|
// content address storage (CAS) and one tombstone for several split
|
||||||
// objects.
|
// objects.
|
||||||
if err := r.Init(new(putsvc.PutInitPrm).
|
if err := r.Init(new(putsvc.PutInitPrm).
|
||||||
WithObject(newTombstone(ownerID, prm.addr.GetContainerID())).
|
WithObject(newTombstone(ownerID, prm.addr.ContainerID())).
|
||||||
WithCommonPrm(prm.common).
|
WithCommonPrm(prm.common).
|
||||||
WithTraverseOption(placement.WithoutSuccessTracking()), // broadcast tombstone, maybe one
|
WithTraverseOption(placement.WithoutSuccessTracking()), // broadcast tombstone, maybe one
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
@ -108,9 +108,9 @@ func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Addr
|
||||||
var res []*objectSDK.Address
|
var res []*objectSDK.Address
|
||||||
|
|
||||||
if linking, err := s.hdrLinking.HeadRelation(ctx, prm.addr, prm.common); err != nil {
|
if linking, err := s.hdrLinking.HeadRelation(ctx, prm.addr, prm.common); err != nil {
|
||||||
cid := prm.addr.GetContainerID()
|
cid := prm.addr.ContainerID()
|
||||||
|
|
||||||
for prev := prm.addr.GetObjectID(); prev != nil; {
|
for prev := prm.addr.ObjectID(); prev != nil; {
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(prev)
|
addr.SetObjectID(prev)
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(cid)
|
||||||
|
@ -124,12 +124,12 @@ func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr := headResult.Header()
|
hdr := headResult.Header()
|
||||||
id := hdr.GetID()
|
id := hdr.ID()
|
||||||
prev = hdr.GetPreviousID()
|
prev = hdr.PreviousID()
|
||||||
|
|
||||||
if rightChild := headResult.RightChild(); rightChild != nil {
|
if rightChild := headResult.RightChild(); rightChild != nil {
|
||||||
id = rightChild.GetID()
|
id = rightChild.ID()
|
||||||
prev = rightChild.GetPreviousID()
|
prev = rightChild.PreviousID()
|
||||||
}
|
}
|
||||||
|
|
||||||
addr.SetObjectID(id)
|
addr.SetObjectID(id)
|
||||||
|
@ -137,20 +137,20 @@ func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Addr
|
||||||
res = append(res, addr)
|
res = append(res, addr)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
childList := linking.GetChildren()
|
childList := linking.Children()
|
||||||
res = make([]*objectSDK.Address, 0, len(childList)+2) // 1 for parent, 1 for linking
|
res = make([]*objectSDK.Address, 0, len(childList)+2) // 1 for parent, 1 for linking
|
||||||
|
|
||||||
for i := range childList {
|
for i := range childList {
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(childList[i])
|
addr.SetObjectID(childList[i])
|
||||||
addr.SetContainerID(prm.addr.GetContainerID())
|
addr.SetContainerID(prm.addr.ContainerID())
|
||||||
|
|
||||||
res = append(res, addr)
|
res = append(res, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(linking.GetID())
|
addr.SetObjectID(linking.ID())
|
||||||
addr.SetContainerID(prm.addr.GetContainerID())
|
addr.SetContainerID(prm.addr.ContainerID())
|
||||||
|
|
||||||
res = append(res, addr)
|
res = append(res, addr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (h *distributedHeader) prepare(ctx context.Context, prm *Prm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get container to store the object
|
// get container to store the object
|
||||||
cnr, err := h.cnrSrc.Get(prm.addr.GetContainerID())
|
cnr, err := h.cnrSrc.Get(prm.addr.ContainerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "(%T) could not get container by ID", h)
|
return errors.Wrapf(err, "(%T) could not get container by ID", h)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func (h *distributedHeader) prepare(ctx context.Context, prm *Prm) error {
|
||||||
placement.SuccessAfter(1),
|
placement.SuccessAfter(1),
|
||||||
|
|
||||||
// set identifier of the processing object
|
// set identifier of the processing object
|
||||||
placement.ForObject(prm.addr.GetObjectID()),
|
placement.ForObject(prm.addr.ObjectID()),
|
||||||
)
|
)
|
||||||
|
|
||||||
// create placement builder from network map
|
// create placement builder from network map
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (h *RelationHeader) HeadRelation(ctx context.Context, addr *objectSDK.Addre
|
||||||
}
|
}
|
||||||
|
|
||||||
a := objectSDK.NewAddress()
|
a := objectSDK.NewAddress()
|
||||||
a.SetContainerID(addr.GetContainerID())
|
a.SetContainerID(addr.ContainerID())
|
||||||
a.SetObjectID(id)
|
a.SetObjectID(id)
|
||||||
|
|
||||||
r, err := h.svc.Head(ctx, new(Prm).
|
r, err := h.svc.Head(ctx, new(Prm).
|
||||||
|
|
|
@ -75,7 +75,7 @@ func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetContainerID(prm.addr.GetContainerID())
|
addr.SetContainerID(prm.addr.ContainerID())
|
||||||
addr.SetObjectID(rightChildID)
|
addr.SetObjectID(rightChildID)
|
||||||
|
|
||||||
r, err = s.Head(ctx, new(Prm).WithAddress(addr).WithCommonPrm(prm.common))
|
r, err = s.Head(ctx, new(Prm).WithAddress(addr).WithCommonPrm(prm.common))
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (t *distributedTarget) Write(p []byte) (n int, err error) {
|
||||||
|
|
||||||
func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||||
traverser, err := placement.NewTraverser(
|
traverser, err := placement.NewTraverser(
|
||||||
append(t.traverseOpts, placement.ForObject(t.obj.GetID()))...,
|
append(t.traverseOpts, placement.ForObject(t.obj.ID()))...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "(%T) could not create object placement traverser", t)
|
return nil, errors.Wrapf(err, "(%T) could not create object placement traverser", t)
|
||||||
|
@ -59,7 +59,7 @@ func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||||
payload = append(payload, t.chunks[i]...)
|
payload = append(payload, t.chunks[i]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.fmt.ValidateContent(t.obj.GetType(), payload); err != nil {
|
if err := t.fmt.ValidateContent(t.obj.Type(), payload); err != nil {
|
||||||
return nil, errors.Wrapf(err, "(%T) could not validate payload content", t)
|
return nil, errors.Wrapf(err, "(%T) could not validate payload content", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,5 +108,5 @@ loop:
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(transformer.AccessIdentifiers).
|
return new(transformer.AccessIdentifiers).
|
||||||
WithSelfID(t.obj.GetID()), nil
|
WithSelfID(t.obj.ID()), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ type localTarget struct {
|
||||||
func (t *localTarget) WriteHeader(obj *object.RawObject) error {
|
func (t *localTarget) WriteHeader(obj *object.RawObject) error {
|
||||||
t.obj = obj
|
t.obj = obj
|
||||||
|
|
||||||
t.payload = make([]byte, 0, obj.GetPayloadSize())
|
t.payload = make([]byte, 0, obj.PayloadSize())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ func (t *localTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(transformer.AccessIdentifiers).
|
return new(transformer.AccessIdentifiers).
|
||||||
WithSelfID(t.obj.GetID()), nil
|
WithSelfID(t.obj.ID()), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (p *Streamer) preparePrm(prm *PutInitPrm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get container to store the object
|
// get container to store the object
|
||||||
cnr, err := p.cnrSrc.Get(prm.hdr.GetContainerID())
|
cnr, err := p.cnrSrc.Get(prm.hdr.ContainerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "(%T) could not get container by ID", p)
|
return errors.Wrapf(err, "(%T) could not get container by ID", p)
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func (p *Streamer) preparePrm(prm *PutInitPrm) error {
|
||||||
placement.ForContainer(cnr),
|
placement.ForContainer(cnr),
|
||||||
|
|
||||||
// set identifier of the processing object
|
// set identifier of the processing object
|
||||||
placement.ForObject(prm.hdr.GetID()),
|
placement.ForObject(prm.hdr.ID()),
|
||||||
)
|
)
|
||||||
|
|
||||||
// create placement builder from network map
|
// create placement builder from network map
|
||||||
|
|
|
@ -23,8 +23,8 @@ type validatingTarget struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *validatingTarget) WriteHeader(obj *object.RawObject) error {
|
func (t *validatingTarget) WriteHeader(obj *object.RawObject) error {
|
||||||
cs := obj.GetPayloadChecksum()
|
cs := obj.PayloadChecksum()
|
||||||
switch typ := cs.GetType(); typ {
|
switch typ := cs.Type(); typ {
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("(%T) unsupported payload checksum type %v", t, typ)
|
return errors.Errorf("(%T) unsupported payload checksum type %v", t, typ)
|
||||||
case pkg.ChecksumSHA256:
|
case pkg.ChecksumSHA256:
|
||||||
|
@ -33,7 +33,7 @@ func (t *validatingTarget) WriteHeader(obj *object.RawObject) error {
|
||||||
t.hash = tz.New()
|
t.hash = tz.New()
|
||||||
}
|
}
|
||||||
|
|
||||||
t.checksum = cs.GetSum()
|
t.checksum = cs.Sum()
|
||||||
|
|
||||||
if err := t.fmt.Validate(obj.Object()); err != nil {
|
if err := t.fmt.Validate(obj.Object()); err != nil {
|
||||||
return errors.Wrapf(err, "(%T) coult not validate object format", t)
|
return errors.Wrapf(err, "(%T) coult not validate object format", t)
|
||||||
|
|
|
@ -35,14 +35,14 @@ type rangeChain struct {
|
||||||
func newRangeTraverser(originSize uint64, rightElement *object.Object, rngSeek *objectSDK.Range) *rangeTraverser {
|
func newRangeTraverser(originSize uint64, rightElement *object.Object, rngSeek *objectSDK.Range) *rangeTraverser {
|
||||||
right := &rangeChain{
|
right := &rangeChain{
|
||||||
bounds: &rangeBounds{
|
bounds: &rangeBounds{
|
||||||
left: originSize - rightElement.GetPayloadSize(),
|
left: originSize - rightElement.PayloadSize(),
|
||||||
right: originSize,
|
right: originSize,
|
||||||
},
|
},
|
||||||
id: rightElement.GetID(),
|
id: rightElement.ID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
left := &rangeChain{
|
left := &rangeChain{
|
||||||
id: rightElement.GetPreviousID(),
|
id: rightElement.PreviousID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
left.next, right.prev = right, left
|
left.next, right.prev = right, left
|
||||||
|
@ -83,12 +83,12 @@ func min(a, b uint64) uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *rangeTraverser) pushHeader(obj *object.Object) {
|
func (c *rangeTraverser) pushHeader(obj *object.Object) {
|
||||||
id := obj.GetID()
|
id := obj.ID()
|
||||||
if !id.Equal(c.chain.prev.id) {
|
if !id.Equal(c.chain.prev.id) {
|
||||||
panic(fmt.Sprintf("(%T) unexpected identifier in header", c))
|
panic(fmt.Sprintf("(%T) unexpected identifier in header", c))
|
||||||
}
|
}
|
||||||
|
|
||||||
sz := obj.GetPayloadSize()
|
sz := obj.PayloadSize()
|
||||||
|
|
||||||
c.chain.prev.bounds = &rangeBounds{
|
c.chain.prev.bounds = &rangeBounds{
|
||||||
left: c.chain.bounds.left - sz,
|
left: c.chain.bounds.left - sz,
|
||||||
|
@ -97,7 +97,7 @@ func (c *rangeTraverser) pushHeader(obj *object.Object) {
|
||||||
|
|
||||||
c.chain = c.chain.prev
|
c.chain = c.chain.prev
|
||||||
|
|
||||||
if prev := obj.GetPreviousID(); prev != nil {
|
if prev := obj.PreviousID(); prev != nil {
|
||||||
c.chain.prev = &rangeChain{
|
c.chain.prev = &rangeChain{
|
||||||
next: c.chain,
|
next: c.chain,
|
||||||
id: prev,
|
id: prev,
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) {
|
||||||
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
|
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := obj.GetPayload()
|
payload := obj.Payload()
|
||||||
left := l.rng.GetOffset()
|
left := l.rng.GetOffset()
|
||||||
right := left + l.rng.GetLength()
|
right := left + l.rng.GetLength()
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) {
|
||||||
|
|
||||||
origin := headResult.Header()
|
origin := headResult.Header()
|
||||||
|
|
||||||
originSize := origin.GetPayloadSize()
|
originSize := origin.PayloadSize()
|
||||||
|
|
||||||
if prm.full {
|
if prm.full {
|
||||||
prm.rng = new(object.Range)
|
prm.rng = new(object.Range)
|
||||||
|
@ -101,7 +101,7 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) {
|
||||||
|
|
||||||
func (s *Service) fillTraverser(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) error {
|
func (s *Service) fillTraverser(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) error {
|
||||||
addr := object.NewAddress()
|
addr := object.NewAddress()
|
||||||
addr.SetContainerID(prm.addr.GetContainerID())
|
addr.SetContainerID(prm.addr.ContainerID())
|
||||||
|
|
||||||
for {
|
for {
|
||||||
nextID, nextRng := traverser.Next()
|
nextID, nextRng := traverser.Next()
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (p *streamer) switchToObject(id *object.ID) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get container to read payload range
|
// get container to read payload range
|
||||||
cnr, err := p.cnrSrc.Get(p.prm.addr.GetContainerID())
|
cnr, err := p.cnrSrc.Get(p.prm.addr.ContainerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "(%T) could not get container by ID", p)
|
return errors.Wrapf(err, "(%T) could not get container by ID", p)
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func (p *streamer) start() {
|
||||||
defer close(p.ch)
|
defer close(p.ch)
|
||||||
|
|
||||||
objAddr := object.NewAddress()
|
objAddr := object.NewAddress()
|
||||||
objAddr.SetContainerID(p.prm.addr.GetContainerID())
|
objAddr.SetContainerID(p.prm.addr.ContainerID())
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (h *distributedHasher) prepare(ctx context.Context, prm *Prm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get container to read the object
|
// get container to read the object
|
||||||
cnr, err := h.cnrSrc.Get(prm.addr.GetContainerID())
|
cnr, err := h.cnrSrc.Get(prm.addr.ContainerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "(%T) could not get container by ID", h)
|
return errors.Wrapf(err, "(%T) could not get container by ID", h)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func (h *distributedHasher) prepare(ctx context.Context, prm *Prm) error {
|
||||||
placement.SuccessAfter(1),
|
placement.SuccessAfter(1),
|
||||||
|
|
||||||
// set identifier of the processing object
|
// set identifier of the processing object
|
||||||
placement.ForObject(prm.addr.GetObjectID()),
|
placement.ForObject(prm.addr.ObjectID()),
|
||||||
)
|
)
|
||||||
|
|
||||||
// create placement builder from network map
|
// create placement builder from network map
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (h *localHasher) hashRange(ctx context.Context, prm *Prm, handler func([][]
|
||||||
return errors.Wrapf(err, "(%T) could not get object from local storage", h)
|
return errors.Wrapf(err, "(%T) could not get object from local storage", h)
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := obj.GetPayload()
|
payload := obj.Payload()
|
||||||
hashes := make([][]byte, 0, len(prm.rngs))
|
hashes := make([][]byte, 0, len(prm.rngs))
|
||||||
|
|
||||||
var hasher hash.Hash
|
var hasher hash.Hash
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm *Prm) (*Response, error)
|
||||||
|
|
||||||
origin := headResult.Header()
|
origin := headResult.Header()
|
||||||
|
|
||||||
originSize := origin.GetPayloadSize()
|
originSize := origin.PayloadSize()
|
||||||
|
|
||||||
var minLeft, maxRight uint64
|
var minLeft, maxRight uint64
|
||||||
for i := range prm.rngs {
|
for i := range prm.rngs {
|
||||||
|
@ -106,7 +106,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm *Prm) (*Response, error)
|
||||||
|
|
||||||
func (s *Service) getHashes(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) (*Response, error) {
|
func (s *Service) getHashes(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) (*Response, error) {
|
||||||
addr := object.NewAddress()
|
addr := object.NewAddress()
|
||||||
addr.SetContainerID(prm.addr.GetContainerID())
|
addr.SetContainerID(prm.addr.ContainerID())
|
||||||
|
|
||||||
resp := &Response{
|
resp := &Response{
|
||||||
hashes: make([][]byte, 0, len(prm.rngs)),
|
hashes: make([][]byte, 0, len(prm.rngs)),
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (s *localStream) stream(ctx context.Context, ch chan<- []*objectSDK.ID) err
|
||||||
idList := make([]*objectSDK.ID, 0, len(addrList))
|
idList := make([]*objectSDK.ID, 0, len(addrList))
|
||||||
|
|
||||||
for i := range addrList {
|
for i := range addrList {
|
||||||
idList = append(idList, addrList[i].GetObjectID())
|
idList = append(idList, addrList[i].ObjectID())
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -21,7 +21,7 @@ var ErrRelationNotFound = errors.New("relation not found")
|
||||||
|
|
||||||
func (s *RelationSearcher) SearchRelation(ctx context.Context, addr *object.Address, prm *util.CommonPrm) (*object.ID, error) {
|
func (s *RelationSearcher) SearchRelation(ctx context.Context, addr *object.Address, prm *util.CommonPrm) (*object.ID, error) {
|
||||||
streamer, err := s.svc.Search(ctx, new(Prm).
|
streamer, err := s.svc.Search(ctx, new(Prm).
|
||||||
WithContainerID(addr.GetContainerID()).WithCommonPrm(prm).
|
WithContainerID(addr.ContainerID()).WithCommonPrm(prm).
|
||||||
WithSearchQuery(s.queryGenerator(addr)),
|
WithSearchQuery(s.queryGenerator(addr)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -65,7 +65,7 @@ func NewRightChildSearcher(svc *Service) *RelationSearcher {
|
||||||
return &RelationSearcher{
|
return &RelationSearcher{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
queryGenerator: func(addr *object.Address) query.Query {
|
queryGenerator: func(addr *object.Address) query.Query {
|
||||||
return queryV1.NewRightChildQuery(addr.GetObjectID())
|
return queryV1.NewRightChildQuery(addr.ObjectID())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func NewLinkingSearcher(svc *Service) *RelationSearcher {
|
||||||
return &RelationSearcher{
|
return &RelationSearcher{
|
||||||
svc: svc,
|
svc: svc,
|
||||||
queryGenerator: func(addr *object.Address) query.Query {
|
queryGenerator: func(addr *object.Address) query.Query {
|
||||||
return queryV1.NewLinkingQuery(addr.GetObjectID())
|
return queryV1.NewLinkingQuery(addr.ObjectID())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,14 @@ type rangeChain struct {
|
||||||
func NewRangeTraverser(originSize uint64, rightElement *object.Object, rngSeek *objectSDK.Range) *RangeTraverser {
|
func NewRangeTraverser(originSize uint64, rightElement *object.Object, rngSeek *objectSDK.Range) *RangeTraverser {
|
||||||
right := &rangeChain{
|
right := &rangeChain{
|
||||||
bounds: &rangeBounds{
|
bounds: &rangeBounds{
|
||||||
left: originSize - rightElement.GetPayloadSize(),
|
left: originSize - rightElement.PayloadSize(),
|
||||||
right: originSize,
|
right: originSize,
|
||||||
},
|
},
|
||||||
id: rightElement.GetID(),
|
id: rightElement.ID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
left := &rangeChain{
|
left := &rangeChain{
|
||||||
id: rightElement.GetPreviousID(),
|
id: rightElement.PreviousID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
left.next, right.prev = right, left
|
left.next, right.prev = right, left
|
||||||
|
@ -75,12 +75,12 @@ func min(a, b uint64) uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RangeTraverser) PushHeader(obj *object.Object) {
|
func (c *RangeTraverser) PushHeader(obj *object.Object) {
|
||||||
id := obj.GetID()
|
id := obj.ID()
|
||||||
if !id.Equal(c.chain.prev.id) {
|
if !id.Equal(c.chain.prev.id) {
|
||||||
panic(fmt.Sprintf("(%T) unexpected identifier in header", c))
|
panic(fmt.Sprintf("(%T) unexpected identifier in header", c))
|
||||||
}
|
}
|
||||||
|
|
||||||
sz := obj.GetPayloadSize()
|
sz := obj.PayloadSize()
|
||||||
|
|
||||||
c.chain.prev.bounds = &rangeBounds{
|
c.chain.prev.bounds = &rangeBounds{
|
||||||
left: c.chain.bounds.left - sz,
|
left: c.chain.bounds.left - sz,
|
||||||
|
@ -89,7 +89,7 @@ func (c *RangeTraverser) PushHeader(obj *object.Object) {
|
||||||
|
|
||||||
c.chain = c.chain.prev
|
c.chain = c.chain.prev
|
||||||
|
|
||||||
if prev := obj.GetPreviousID(); prev != nil {
|
if prev := obj.PreviousID(); prev != nil {
|
||||||
c.chain.prev = &rangeChain{
|
c.chain.prev = &rangeChain{
|
||||||
next: c.chain,
|
next: c.chain,
|
||||||
id: prev,
|
id: prev,
|
||||||
|
|
|
@ -116,8 +116,8 @@ func (gc *GC) Run(ctx context.Context) {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
gc.log.Info("object removed",
|
gc.log.Info("object removed",
|
||||||
zap.String("CID", stringifyCID(addr.GetContainerID())),
|
zap.String("CID", stringifyCID(addr.ContainerID())),
|
||||||
zap.String("ID", stringifyID(addr.GetObjectID())),
|
zap.String("ID", stringifyID(addr.ObjectID())),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ func UseBuilder(b Builder) Option {
|
||||||
// ForContainer is a traversal container setting option.
|
// ForContainer is a traversal container setting option.
|
||||||
func ForContainer(cnr *container.Container) Option {
|
func ForContainer(cnr *container.Container) Option {
|
||||||
return func(c *cfg) {
|
return func(c *cfg) {
|
||||||
c.policy = netmap.NewPlacementPolicyFromV2(cnr.GetPlacementPolicy())
|
c.policy = cnr.PlacementPolicy()
|
||||||
c.addr.SetContainerID(container.CalculateID(cnr))
|
c.addr.SetContainerID(container.CalculateID(cnr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
||||||
|
|
||||||
var parID *objectSDK.ID
|
var parID *objectSDK.ID
|
||||||
|
|
||||||
if par := f.obj.GetParent(); par != nil {
|
if par := f.obj.Parent(); par != nil {
|
||||||
rawPar := objectSDK.NewRawFromV2(par.ToV2())
|
rawPar := objectSDK.NewRawFromV2(par.ToV2())
|
||||||
|
|
||||||
rawPar.SetSessionToken(f.prm.SessionToken)
|
rawPar.SetSessionToken(f.prm.SessionToken)
|
||||||
|
@ -81,7 +81,7 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
||||||
return nil, errors.Wrap(err, "could not finalize parent object")
|
return nil, errors.Wrap(err, "could not finalize parent object")
|
||||||
}
|
}
|
||||||
|
|
||||||
parID = rawPar.GetID()
|
parID = rawPar.ID()
|
||||||
|
|
||||||
f.obj.SetParent(rawPar.Object())
|
f.obj.SetParent(rawPar.Object())
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,6 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(AccessIdentifiers).
|
return new(AccessIdentifiers).
|
||||||
WithSelfID(f.obj.GetID()).
|
WithSelfID(f.obj.ID()).
|
||||||
WithParentID(parID), nil
|
WithParentID(parID), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,10 @@ func (s *payloadSizeLimiter) initialize() {
|
||||||
|
|
||||||
func fromObject(obj *object.RawObject) *object.RawObject {
|
func fromObject(obj *object.RawObject) *object.RawObject {
|
||||||
res := object.NewRaw()
|
res := object.NewRaw()
|
||||||
res.SetContainerID(obj.GetContainerID())
|
res.SetContainerID(obj.ContainerID())
|
||||||
res.SetOwnerID(obj.GetOwnerID())
|
res.SetOwnerID(obj.OwnerID())
|
||||||
res.SetAttributes(obj.GetAttributes()...)
|
res.SetAttributes(obj.Attributes()...)
|
||||||
res.SetType(obj.GetType())
|
res.SetType(obj.Type())
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ func writeHashes(hashers []*payloadChecksumHasher) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *payloadSizeLimiter) initializeLinking() {
|
func (s *payloadSizeLimiter) initializeLinking() {
|
||||||
id := s.current.GetParentID()
|
id := s.current.ParentID()
|
||||||
|
|
||||||
s.current = fromObject(s.current)
|
s.current = fromObject(s.current)
|
||||||
s.current.SetParentID(id)
|
s.current.SetParentID(id)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Policer) processObject(ctx context.Context, addr *object.Address) {
|
func (p *Policer) processObject(ctx context.Context, addr *object.Address) {
|
||||||
cnr, err := p.cnrSrc.Get(addr.GetContainerID())
|
cnr, err := p.cnrSrc.Get(addr.ContainerID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Error("could not get container",
|
p.log.Error("could not get container",
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -22,7 +22,7 @@ func (p *Policer) processObject(ctx context.Context, addr *object.Address) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
policy := netmap.NewPlacementPolicyFromV2(cnr.GetPlacementPolicy())
|
policy := cnr.PlacementPolicy()
|
||||||
|
|
||||||
nn, err := p.placementBuilder.BuildPlacement(addr, policy)
|
nn, err := p.placementBuilder.BuildPlacement(addr, policy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue