forked from TrueCloudLab/frostfs-node
[#570] *: Remove usage of deprecated elements from API Go library
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
70a7354e9d
commit
3dd10b6795
63 changed files with 285 additions and 270 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"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/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"
|
||||||
|
@ -79,7 +80,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
Long: "List all created containers",
|
Long: "List all created containers",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
var (
|
var (
|
||||||
response []*container.ID
|
response []*cid.ID
|
||||||
oid *owner.ID
|
oid *owner.ID
|
||||||
err error
|
err error
|
||||||
|
|
||||||
|
@ -413,7 +414,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
eaclTable := res.EACL()
|
eaclTable := res.EACL()
|
||||||
sig := res.Signature()
|
sig := eaclTable.Signature()
|
||||||
|
|
||||||
if containerPathTo == "" {
|
if containerPathTo == "" {
|
||||||
fmt.Println("eACL: ")
|
fmt.Println("eACL: ")
|
||||||
|
@ -613,7 +614,7 @@ func containerSessionToken() (*session.Token, error) {
|
||||||
return tok, nil
|
return tok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func prettyPrintContainerList(list []*container.ID) {
|
func prettyPrintContainerList(list []*cid.ID) {
|
||||||
for i := range list {
|
for i := range list {
|
||||||
fmt.Println(list[i])
|
fmt.Println(list[i])
|
||||||
}
|
}
|
||||||
|
@ -713,14 +714,14 @@ func parseNonce(nonce string) (uuid.UUID, error) {
|
||||||
return uuid.Parse(nonce)
|
return uuid.Parse(nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseContainerID(cid string) (*container.ID, error) {
|
func parseContainerID(idStr string) (*cid.ID, error) {
|
||||||
if cid == "" {
|
if idStr == "" {
|
||||||
return nil, errors.New("container ID is not set")
|
return nil, errors.New("container ID is not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
|
|
||||||
err := id.Parse(cid)
|
err := id.Parse(idStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("can't decode container ID value")
|
return nil, errors.New("can't decode container ID value")
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"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/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/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -193,7 +194,7 @@ func init() {
|
||||||
// objectCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
// objectCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||||
}
|
}
|
||||||
|
|
||||||
func initSession(ctx context.Context) (client.Client, *token.SessionToken, error) {
|
func initSession(ctx context.Context) (client.Client, *session.Token, error) {
|
||||||
key, err := getKey()
|
key, err := getKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("can't fetch private key: %w", err)
|
return nil, nil, fmt.Errorf("can't fetch private key: %w", err)
|
||||||
|
@ -665,11 +666,11 @@ func parseObjectAttrs(cmd *cobra.Command) ([]*object.Attribute, error) {
|
||||||
return attrs, nil
|
return attrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCID(cmd *cobra.Command) (*container.ID, error) {
|
func getCID(cmd *cobra.Command) (*cid.ID, error) {
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
err := cid.Parse(cmd.Flag("cid").Value.String())
|
err := id.Parse(cmd.Flag("cid").Value.String())
|
||||||
|
|
||||||
return cid, err
|
return id, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getOID(cmd *cobra.Command) (*object.ID, error) {
|
func getOID(cmd *cobra.Command) (*object.ID, error) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
storagegroupAPI "github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
storagegroupAPI "github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -93,7 +94,7 @@ func init() {
|
||||||
type sgHeadReceiver struct {
|
type sgHeadReceiver struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
tok *token.SessionToken
|
tok *session.Token
|
||||||
|
|
||||||
c client.Client
|
c client.Client
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
|
@ -134,20 +135,20 @@ func newCachedContainerStorage(v container.Source) container.Source {
|
||||||
)
|
)
|
||||||
|
|
||||||
lruCnrCache := newNetworkTTLCache(containerCacheSize, containerCacheTTL, func(key interface{}) (interface{}, error) {
|
lruCnrCache := newNetworkTTLCache(containerCacheSize, containerCacheTTL, func(key interface{}) (interface{}, error) {
|
||||||
cid := containerSDK.NewID()
|
id := cid.New()
|
||||||
|
|
||||||
err := cid.Parse(key.(string))
|
err := id.Parse(key.(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.Get(cid)
|
return v.Get(id)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (*ttlContainerStorage)(lruCnrCache)
|
return (*ttlContainerStorage)(lruCnrCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ttlContainerStorage) Get(cid *containerSDK.ID) (*containerSDK.Container, error) {
|
func (s *ttlContainerStorage) Get(cid *cid.ID) (*containerSDK.Container, error) {
|
||||||
val, err := (*ttlNetCache)(s).get(cid.String())
|
val, err := (*ttlNetCache)(s).get(cid.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -165,20 +166,20 @@ func newCachedEACLStorage(v eacl.Storage) eacl.Storage {
|
||||||
)
|
)
|
||||||
|
|
||||||
lruCnrCache := newNetworkTTLCache(eaclCacheSize, eaclCacheTTL, func(key interface{}) (interface{}, error) {
|
lruCnrCache := newNetworkTTLCache(eaclCacheSize, eaclCacheTTL, func(key interface{}) (interface{}, error) {
|
||||||
cid := containerSDK.NewID()
|
id := cid.New()
|
||||||
|
|
||||||
err := cid.Parse(key.(string))
|
err := id.Parse(key.(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.GetEACL(cid)
|
return v.GetEACL(id)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (*ttlEACLStorage)(lruCnrCache)
|
return (*ttlEACLStorage)(lruCnrCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ttlEACLStorage) GetEACL(cid *containerSDK.ID) (*eaclSDK.Table, error) {
|
func (s *ttlEACLStorage) GetEACL(cid *cid.ID) (*eaclSDK.Table, error) {
|
||||||
val, err := (*ttlNetCache)(s).get(cid.String())
|
val, err := (*ttlNetCache)(s).get(cid.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
|
apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
containerSDK "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/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
containerV2 "github.com/nspcc-dev/neofs-api-go/v2/container"
|
containerV2 "github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||||
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||||
|
@ -279,7 +280,7 @@ type loadPlacementBuilder struct {
|
||||||
cnrSrc containerCore.Source
|
cnrSrc containerCore.Source
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *loadPlacementBuilder) BuildPlacement(epoch uint64, cid *containerSDK.ID) ([]netmap.Nodes, error) {
|
func (l *loadPlacementBuilder) BuildPlacement(epoch uint64, cid *cid.ID) ([]netmap.Nodes, error) {
|
||||||
cnrNodes, nm, err := l.buildPlacement(epoch, cid)
|
cnrNodes, nm, err := l.buildPlacement(epoch, cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -299,7 +300,7 @@ func (l *loadPlacementBuilder) BuildPlacement(epoch uint64, cid *containerSDK.ID
|
||||||
return placement, nil
|
return placement, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *loadPlacementBuilder) buildPlacement(epoch uint64, cid *containerSDK.ID) (netmap.ContainerNodes, *netmap.Netmap, error) {
|
func (l *loadPlacementBuilder) buildPlacement(epoch uint64, cid *cid.ID) (netmap.ContainerNodes, *netmap.Netmap, error) {
|
||||||
cnr, err := l.cnrSrc.Get(cid)
|
cnr, err := l.cnrSrc.Get(cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
@ -433,7 +434,7 @@ func (*containerOnlyKeyRemoteServerInfo) Address() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *loadPlacementBuilder) isNodeFromContainerKey(epoch uint64, cid *containerSDK.ID, key []byte) (bool, error) {
|
func (l *loadPlacementBuilder) isNodeFromContainerKey(epoch uint64, cid *cid.ID, key []byte) (bool, error) {
|
||||||
cnrNodes, _, err := l.buildPlacement(epoch, cid)
|
cnrNodes, _, err := l.buildPlacement(epoch, cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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/util/signature"
|
"github.com/nspcc-dev/neofs-api-go/util/signature"
|
||||||
|
@ -372,7 +372,7 @@ func (s *signedEACLTable) SignedDataSize() int {
|
||||||
return (*eaclSDK.Table)(s).ToV2().StableSize()
|
return (*eaclSDK.Table)(s).ToV2().StableSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphEACLStorage) GetEACL(cid *container.ID) (*eaclSDK.Table, error) {
|
func (s *morphEACLStorage) GetEACL(cid *cid.ID) (*eaclSDK.Table, error) {
|
||||||
table, err := s.w.GetEACL(cid)
|
table, err := s.w.GetEACL(cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Source is an interface that wraps
|
// Source is an interface that wraps
|
||||||
|
@ -17,7 +18,7 @@ type Source interface {
|
||||||
//
|
//
|
||||||
// Implementations must not retain the container pointer and modify
|
// Implementations must not retain the container pointer and modify
|
||||||
// the container through it.
|
// the container through it.
|
||||||
Get(*container.ID) (*container.Container, error)
|
Get(*cid.ID) (*container.Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNotFound is the error returned when container was not found in storage.
|
// ErrNotFound is the error returned when container was not found in storage.
|
||||||
|
|
|
@ -8,11 +8,11 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/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/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/test"
|
"github.com/nspcc-dev/neofs-node/pkg/util/test"
|
||||||
|
@ -28,8 +28,8 @@ func testSHA(t *testing.T) [sha256.Size]byte {
|
||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
|
|
||||||
func testContainerID(t *testing.T) *container.ID {
|
func testContainerID(t *testing.T) *cid.ID {
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(testSHA(t))
|
id.SetSHA256(testSHA(t))
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
@ -101,7 +101,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("correct w/ session token", func(t *testing.T) {
|
t.Run("correct w/ session token", func(t *testing.T) {
|
||||||
tok := token.NewSessionToken()
|
tok := session.NewToken()
|
||||||
tok.SetSessionKey(crypto.MarshalPublicKey(&ownerKey.PublicKey))
|
tok.SetSessionKey(crypto.MarshalPublicKey(&ownerKey.PublicKey))
|
||||||
|
|
||||||
obj := NewRaw()
|
obj := NewRaw()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"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/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-node/pkg/morph/client/container/wrapper"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||||
|
@ -105,7 +105,7 @@ func (ap *Processor) processStartAudit(epoch uint64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ap *Processor) findStorageGroups(cid *container.ID, shuffled netmap.Nodes) []*object.ID {
|
func (ap *Processor) findStorageGroups(cid *cid.ID, shuffled netmap.Nodes) []*object.ID {
|
||||||
var sg []*object.ID
|
var sg []*object.ID
|
||||||
|
|
||||||
ln := len(shuffled)
|
ln := len(shuffled)
|
||||||
|
|
|
@ -6,13 +6,13 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrInvalidIRNode = errors.New("node is not in the inner ring list")
|
var ErrInvalidIRNode = errors.New("node is not in the inner ring list")
|
||||||
|
|
||||||
func (ap *Processor) selectContainersToAudit(epoch uint64) ([]*container.ID, error) {
|
func (ap *Processor) selectContainersToAudit(epoch uint64) ([]*cid.ID, error) {
|
||||||
containers, err := ap.containerClient.List(nil)
|
containers, err := ap.containerClient.List(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't get list of containers to start audit: %w", err)
|
return nil, fmt.Errorf("can't get list of containers to start audit: %w", err)
|
||||||
|
@ -38,7 +38,7 @@ func (ap *Processor) selectContainersToAudit(epoch uint64) ([]*container.ID, err
|
||||||
return Select(containers, epoch, uint64(ind), uint64(irSize)), nil
|
return Select(containers, epoch, uint64(ind), uint64(irSize)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Select(ids []*container.ID, epoch, index, size uint64) []*container.ID {
|
func Select(ids []*cid.ID, epoch, index, size uint64) []*cid.ID {
|
||||||
if index >= size {
|
if index >= size {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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-node/pkg/innerring/processors/audit"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -76,23 +76,23 @@ func TestSelect(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateContainers(n int) []*container.ID {
|
func generateContainers(n int) []*cid.ID {
|
||||||
var buf [sha256.Size]byte
|
var buf [sha256.Size]byte
|
||||||
result := make([]*container.ID, 0, n)
|
result := make([]*cid.ID, 0, n)
|
||||||
|
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
_, _ = rand.Read(buf[:])
|
_, _ = rand.Read(buf[:])
|
||||||
|
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256(buf)
|
id.SetSHA256(buf)
|
||||||
|
|
||||||
result = append(result, cid)
|
result = append(result, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func hitMap(ids []*container.ID) map[string]int {
|
func hitMap(ids []*cid.ID) map[string]int {
|
||||||
result := make(map[string]int, len(ids))
|
result := make(map[string]int, len(ids))
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||||
"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/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"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
|
@ -29,7 +29,7 @@ type singleResultCtx struct {
|
||||||
|
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
|
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
|
|
||||||
txTable *common.TransferTable
|
txTable *common.TransferTable
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ func (c *Calculator) fillTransferTable(ctx *singleResultCtx) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *singleResultCtx) containerID() *container.ID {
|
func (c *singleResultCtx) containerID() *cid.ID {
|
||||||
if c.cid == nil {
|
if c.cid == nil {
|
||||||
c.cid = c.auditResult.ContainerID()
|
c.cid = c.auditResult.ContainerID()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package common
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ type ContainerInfo interface {
|
||||||
// storage of the NeoFS containers.
|
// storage of the NeoFS containers.
|
||||||
type ContainerStorage interface {
|
type ContainerStorage interface {
|
||||||
// Must return information about the container by ID.
|
// Must return information about the container by ID.
|
||||||
ContainerInfo(*container.ID) (ContainerInfo, error)
|
ContainerInfo(*cid.ID) (ContainerInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlacementCalculator is a component interface
|
// PlacementCalculator is a component interface
|
||||||
// that builds placement vectors.
|
// that builds placement vectors.
|
||||||
type PlacementCalculator interface {
|
type PlacementCalculator interface {
|
||||||
// Must return information about the nodes from container cid of the epoch e.
|
// Must return information about the nodes from container cid of the epoch e.
|
||||||
ContainerNodes(e uint64, cid *container.ID) ([]NodeInfo, error)
|
ContainerNodes(e uint64, cid *cid.ID) ([]NodeInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountStorage is an network member accounts interface.
|
// AccountStorage is an network member accounts interface.
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||||
containerAPI "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
containerAPI "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
netmapAPI "github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
netmapAPI "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"
|
||||||
|
@ -108,7 +109,7 @@ func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result,
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s settlementDeps) ContainerInfo(cid *containerAPI.ID) (common.ContainerInfo, error) {
|
func (s settlementDeps) ContainerInfo(cid *cid.ID) (common.ContainerInfo, error) {
|
||||||
cnr, err := s.cnrSrc.Get(cid)
|
cnr, err := s.cnrSrc.Get(cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not get container from storage: %w", err)
|
return nil, fmt.Errorf("could not get container from storage: %w", err)
|
||||||
|
@ -117,7 +118,7 @@ func (s settlementDeps) ContainerInfo(cid *containerAPI.ID) (common.ContainerInf
|
||||||
return (*containerWrapper)(cnr), nil
|
return (*containerWrapper)(cnr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s settlementDeps) buildContainer(e uint64, cid *containerAPI.ID) (netmapAPI.ContainerNodes, *netmapAPI.Netmap, error) {
|
func (s settlementDeps) buildContainer(e uint64, cid *cid.ID) (netmapAPI.ContainerNodes, *netmapAPI.Netmap, error) {
|
||||||
var (
|
var (
|
||||||
nm *netmapAPI.Netmap
|
nm *netmapAPI.Netmap
|
||||||
err error
|
err error
|
||||||
|
@ -149,7 +150,7 @@ func (s settlementDeps) buildContainer(e uint64, cid *containerAPI.ID) (netmapAP
|
||||||
return cn, nm, nil
|
return cn, nm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s settlementDeps) ContainerNodes(e uint64, cid *containerAPI.ID) ([]common.NodeInfo, error) {
|
func (s settlementDeps) ContainerNodes(e uint64, cid *cid.ID) ([]common.NodeInfo, error) {
|
||||||
cn, _, err := s.buildContainer(e, cid)
|
cn, _, err := s.buildContainer(e, cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
||||||
|
@ -21,15 +21,15 @@ func testSHA256() (h [sha256.Size]byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAddress() *objectSDK.Address {
|
func testAddress() *objectSDK.Address {
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256(testSHA256())
|
id.SetSHA256(testSHA256())
|
||||||
|
|
||||||
oid := objectSDK.NewID()
|
oid := objectSDK.NewID()
|
||||||
oid.SetSHA256(testSHA256())
|
oid.SetSHA256(testSHA256())
|
||||||
|
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(oid)
|
addr.SetObjectID(oid)
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(id)
|
||||||
|
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
|
||||||
|
@ -21,15 +21,15 @@ func testSHA256() (h [sha256.Size]byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAddress() *objectSDK.Address {
|
func testAddress() *objectSDK.Address {
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256(testSHA256())
|
id.SetSHA256(testSHA256())
|
||||||
|
|
||||||
oid := objectSDK.NewID()
|
oid := objectSDK.NewID()
|
||||||
oid.SetSHA256(testSHA256())
|
oid.SetSHA256(testSHA256())
|
||||||
|
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(oid)
|
addr.SetObjectID(oid)
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(id)
|
||||||
|
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@ func addressFromString(s string) (*objectSDK.Address, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
if err := cid.Parse(ss[1]); err != nil {
|
if err := id.Parse(ss[1]); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(oid)
|
addr.SetObjectID(oid)
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(id)
|
||||||
|
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,16 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testCID() *container.ID {
|
func testCID() *cid.ID {
|
||||||
cs := [sha256.Size]byte{}
|
cs := [sha256.Size]byte{}
|
||||||
_, _ = rand.Read(cs[:])
|
_, _ = rand.Read(cs[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(cs)
|
id.SetSHA256(cs)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"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-node/pkg/local_object_storage/shard"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerSizePrm struct {
|
type ContainerSizePrm struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerSizeRes struct {
|
type ContainerSizeRes struct {
|
||||||
|
@ -17,10 +17,10 @@ type ContainerSizeRes struct {
|
||||||
type ListContainersPrm struct{}
|
type ListContainersPrm struct{}
|
||||||
|
|
||||||
type ListContainersRes struct {
|
type ListContainersRes struct {
|
||||||
containers []*container.ID
|
containers []*cid.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ContainerSizePrm) WithContainerID(cid *container.ID) *ContainerSizePrm {
|
func (p *ContainerSizePrm) WithContainerID(cid *cid.ID) *ContainerSizePrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.cid = cid
|
p.cid = cid
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func (r *ContainerSizeRes) Size() uint64 {
|
||||||
return r.size
|
return r.size
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ListContainersRes) Containers() []*container.ID {
|
func (r *ListContainersRes) Containers() []*cid.ID {
|
||||||
return r.containers
|
return r.containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ func (e *StorageEngine) ContainerSize(prm *ContainerSizePrm) *ContainerSizeRes {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerSize returns sum of estimation container sizes among all shards.
|
// ContainerSize returns sum of estimation container sizes among all shards.
|
||||||
func ContainerSize(e *StorageEngine, id *container.ID) uint64 {
|
func ContainerSize(e *StorageEngine, id *cid.ID) uint64 {
|
||||||
return e.ContainerSize(&ContainerSizePrm{cid: id}).Size()
|
return e.ContainerSize(&ContainerSizePrm{cid: id}).Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *StorageEngine) containerSize(id *container.ID) (total uint64) {
|
func (e *StorageEngine) containerSize(id *cid.ID) (total uint64) {
|
||||||
e.iterateOverUnsortedShards(func(s *shard.Shard) (stop bool) {
|
e.iterateOverUnsortedShards(func(s *shard.Shard) (stop bool) {
|
||||||
size, err := shard.ContainerSize(s, id)
|
size, err := shard.ContainerSize(s, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -84,12 +84,12 @@ func (e *StorageEngine) ListContainers(_ *ListContainersPrm) *ListContainersRes
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListContainers returns unique container IDs presented in the engine objects.
|
// ListContainers returns unique container IDs presented in the engine objects.
|
||||||
func ListContainers(e *StorageEngine) []*container.ID {
|
func ListContainers(e *StorageEngine) []*cid.ID {
|
||||||
return e.ListContainers(&ListContainersPrm{}).Containers()
|
return e.ListContainers(&ListContainersPrm{}).Containers()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *StorageEngine) listContainers() []*container.ID {
|
func (e *StorageEngine) listContainers() []*cid.ID {
|
||||||
uniqueIDs := make(map[string]*container.ID)
|
uniqueIDs := make(map[string]*cid.ID)
|
||||||
|
|
||||||
e.iterateOverUnsortedShards(func(s *shard.Shard) (stop bool) {
|
e.iterateOverUnsortedShards(func(s *shard.Shard) (stop bool) {
|
||||||
cnrs, err := shard.ListContainers(s)
|
cnrs, err := shard.ListContainers(s)
|
||||||
|
@ -111,7 +111,7 @@ func (e *StorageEngine) listContainers() []*container.ID {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
result := make([]*container.ID, 0, len(uniqueIDs))
|
result := make([]*cid.ID, 0, len(uniqueIDs))
|
||||||
for _, v := range uniqueIDs {
|
for _, v := range uniqueIDs {
|
||||||
result = append(result, v)
|
result = append(result, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -61,11 +61,11 @@ func testNewShard(t *testing.T, id int) *shard.Shard {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCID() *container.ID {
|
func testCID() *cid.ID {
|
||||||
cs := [sha256.Size]byte{}
|
cs := [sha256.Size]byte{}
|
||||||
_, _ = rand.Read(cs[:])
|
_, _ = rand.Read(cs[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(cs)
|
id.SetSHA256(cs)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
@ -81,7 +81,7 @@ func testOID() *objectSDK.ID {
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRawObjectWithCID(t *testing.T, cid *container.ID) *object.RawObject {
|
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
||||||
version := pkg.NewVersion()
|
version := pkg.NewVersion()
|
||||||
version.SetMajor(2)
|
version.SetMajor(2)
|
||||||
version.SetMinor(1)
|
version.SetMinor(1)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package engine
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||||
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
// SelectPrm groups the parameters of Select operation.
|
// SelectPrm groups the parameters of Select operation.
|
||||||
type SelectPrm struct {
|
type SelectPrm struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
filters object.SearchFilters
|
filters object.SearchFilters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ type SelectRes struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContainerID is a Select option to set the container id to search in.
|
// WithContainerID is a Select option to set the container id to search in.
|
||||||
func (p *SelectPrm) WithContainerID(cid *container.ID) *SelectPrm {
|
func (p *SelectPrm) WithContainerID(cid *cid.ID) *SelectPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.cid = cid
|
p.cid = cid
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func (e *StorageEngine) List(limit uint64) (*SelectRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select selects objects from local storage using provided filters.
|
// Select selects objects from local storage using provided filters.
|
||||||
func Select(storage *StorageEngine, cid *container.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
func Select(storage *StorageEngine, cid *cid.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
||||||
res, err := storage.Select(new(SelectPrm).
|
res, err := storage.Select(new(SelectPrm).
|
||||||
WithContainerID(cid).
|
WithContainerID(cid).
|
||||||
WithFilters(fs),
|
WithFilters(fs),
|
||||||
|
|
|
@ -4,11 +4,11 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (db *DB) Containers() (list []*container.ID, err error) {
|
func (db *DB) Containers() (list []*cid.ID, err error) {
|
||||||
err = db.boltDB.View(func(tx *bbolt.Tx) error {
|
err = db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||||
list, err = db.containers(tx)
|
list, err = db.containers(tx)
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ func (db *DB) Containers() (list []*container.ID, err error) {
|
||||||
return list, err
|
return list, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) containers(tx *bbolt.Tx) ([]*container.ID, error) {
|
func (db *DB) containers(tx *bbolt.Tx) ([]*cid.ID, error) {
|
||||||
result := make([]*container.ID, 0)
|
result := make([]*cid.ID, 0)
|
||||||
|
|
||||||
err := tx.ForEach(func(name []byte, _ *bbolt.Bucket) error {
|
err := tx.ForEach(func(name []byte, _ *bbolt.Bucket) error {
|
||||||
id, err := parseContainerID(name)
|
id, err := parseContainerID(name)
|
||||||
|
@ -37,7 +37,7 @@ func (db *DB) containers(tx *bbolt.Tx) ([]*container.ID, error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) ContainerSize(id *container.ID) (size uint64, err error) {
|
func (db *DB) ContainerSize(id *cid.ID) (size uint64, err error) {
|
||||||
err = db.boltDB.Update(func(tx *bbolt.Tx) error {
|
err = db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
size, err = db.containerSize(tx, id)
|
size, err = db.containerSize(tx, id)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func (db *DB) ContainerSize(id *container.ID) (size uint64, err error) {
|
||||||
return size, err
|
return size, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) containerSize(tx *bbolt.Tx, id *container.ID) (uint64, error) {
|
func (db *DB) containerSize(tx *bbolt.Tx, id *cid.ID) (uint64, error) {
|
||||||
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
@ -58,14 +58,14 @@ func (db *DB) containerSize(tx *bbolt.Tx, id *container.ID) (uint64, error) {
|
||||||
return parseContainerSize(containerVolume.Get(key)), nil
|
return parseContainerSize(containerVolume.Get(key)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseContainerID(name []byte) (*container.ID, error) {
|
func parseContainerID(name []byte) (*cid.ID, error) {
|
||||||
strName := string(name)
|
strName := string(name)
|
||||||
|
|
||||||
if strings.Contains(strName, invalidBase58String) {
|
if strings.Contains(strName, invalidBase58String) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
|
|
||||||
return id, id.Parse(strName)
|
return id, id.Parse(strName)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func parseContainerSize(v []byte) uint64 {
|
||||||
return binary.LittleEndian.Uint64(v)
|
return binary.LittleEndian.Uint64(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func changeContainerSize(tx *bbolt.Tx, id *container.ID, delta uint64, increase bool) error {
|
func changeContainerSize(tx *bbolt.Tx, id *cid.ID, delta uint64, increase bool) error {
|
||||||
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -80,8 +80,8 @@ func TestDB_ContainerSize(t *testing.T) {
|
||||||
N = 5
|
N = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
cids := make(map[*container.ID]int, C)
|
cids := make(map[*cid.ID]int, C)
|
||||||
objs := make(map[*container.ID][]*object.RawObject, C*N)
|
objs := make(map[*cid.ID][]*object.RawObject, C*N)
|
||||||
|
|
||||||
for i := 0; i < C; i++ {
|
for i := 0; i < C; i++ {
|
||||||
cid := testCID()
|
cid := testCID()
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -22,7 +22,7 @@ func putBig(db *meta.DB, obj *object.Object) error {
|
||||||
return meta.Put(db, obj, nil)
|
return meta.Put(db, obj, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSelect(t *testing.T, db *meta.DB, cid *container.ID, fs objectSDK.SearchFilters, exp ...*objectSDK.Address) {
|
func testSelect(t *testing.T, db *meta.DB, cid *cid.ID, fs objectSDK.SearchFilters, exp ...*objectSDK.Address) {
|
||||||
res, err := meta.Select(db, cid, fs)
|
res, err := meta.Select(db, cid, fs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, res, len(exp))
|
require.Len(t, res, len(exp))
|
||||||
|
@ -32,11 +32,11 @@ func testSelect(t *testing.T, db *meta.DB, cid *container.ID, fs objectSDK.Searc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCID() *container.ID {
|
func testCID() *cid.ID {
|
||||||
cs := [sha256.Size]byte{}
|
cs := [sha256.Size]byte{}
|
||||||
_, _ = rand.Read(cs[:])
|
_, _ = rand.Read(cs[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(cs)
|
id.SetSHA256(cs)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
@ -71,7 +71,7 @@ func generateRawObject(t *testing.T) *object.RawObject {
|
||||||
return generateRawObjectWithCID(t, testCID())
|
return generateRawObjectWithCID(t, testCID())
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRawObjectWithCID(t *testing.T, cid *container.ID) *object.RawObject {
|
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
||||||
version := pkg.NewVersion()
|
version := pkg.NewVersion()
|
||||||
version.SetMajor(2)
|
version.SetMajor(2)
|
||||||
version.SetMinor(1)
|
version.SetMinor(1)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
|
@ -119,7 +119,7 @@ func inBucket(tx *bbolt.Tx, name, key []byte) bool {
|
||||||
|
|
||||||
// getSplitInfo returns SplitInfo structure from root index. Returns error
|
// getSplitInfo returns SplitInfo structure from root index. Returns error
|
||||||
// if there is no `key` record in root index.
|
// if there is no `key` record in root index.
|
||||||
func getSplitInfo(tx *bbolt.Tx, cid *container.ID, key []byte) (*objectSDK.SplitInfo, error) {
|
func getSplitInfo(tx *bbolt.Tx, cid *cid.ID, key []byte) (*objectSDK.SplitInfo, error) {
|
||||||
rawSplitInfo := getFromBucket(tx, rootBucketName(cid), key)
|
rawSplitInfo := getFromBucket(tx, rootBucketName(cid), key)
|
||||||
if len(rawSplitInfo) == 0 {
|
if len(rawSplitInfo) == 0 {
|
||||||
return nil, ErrLackSplitInfo
|
return nil, ErrLackSplitInfo
|
||||||
|
|
|
@ -3,7 +3,7 @@ package meta
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
|
@ -120,7 +120,7 @@ func getFromBucket(tx *bbolt.Tx, name, key []byte) []byte {
|
||||||
return bkt.Get(key)
|
return bkt.Get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVirtualObject(tx *bbolt.Tx, cid *container.ID, key []byte, raw bool) (*object.Object, error) {
|
func getVirtualObject(tx *bbolt.Tx, cid *cid.ID, key []byte, raw bool) (*object.Object, error) {
|
||||||
if raw {
|
if raw {
|
||||||
return nil, getSplitInfoError(tx, cid, key)
|
return nil, getSplitInfoError(tx, cid, key)
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func getVirtualObject(tx *bbolt.Tx, cid *container.ID, key []byte, raw bool) (*o
|
||||||
return child.GetParent(), nil
|
return child.GetParent(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSplitInfoError(tx *bbolt.Tx, cid *container.ID, key []byte) error {
|
func getSplitInfoError(tx *bbolt.Tx, cid *cid.ID, key []byte) error {
|
||||||
splitInfo, err := getSplitInfo(tx, cid, key)
|
splitInfo, err := getSplitInfo(tx, cid, key)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return objectSDK.NewSplitInfoError(splitInfo)
|
return objectSDK.NewSplitInfoError(splitInfo)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/object"
|
"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"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
|
@ -74,19 +74,19 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
|
||||||
return fmt.Errorf("could not parse ID of expired object: %w", err)
|
return fmt.Errorf("could not parse ID of expired object: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cid := container.NewID()
|
cnrID := cid.New()
|
||||||
|
|
||||||
err = cid.Parse(string(cidBytes))
|
err = cnrID.Parse(string(cidBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not parse container ID of expired bucket: %w", err)
|
return fmt.Errorf("could not parse container ID of expired bucket: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := object.NewAddress()
|
addr := object.NewAddress()
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(cnrID)
|
||||||
addr.SetObjectID(id)
|
addr.SetObjectID(id)
|
||||||
|
|
||||||
return h(&ExpiredObject{
|
return h(&ExpiredObject{
|
||||||
typ: objectType(tx, cid, idKey),
|
typ: objectType(tx, cnrID, idKey),
|
||||||
addr: addr,
|
addr: addr,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -100,7 +100,7 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func objectType(tx *bbolt.Tx, cid *container.ID, oidBytes []byte) object.Type {
|
func objectType(tx *bbolt.Tx, cid *cid.ID, oidBytes []byte) object.Type {
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
return object.TypeRegular
|
return object.TypeRegular
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
|
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
|
@ -19,7 +19,7 @@ type (
|
||||||
// objects, and slow filters, that applied after fast filters created
|
// objects, and slow filters, that applied after fast filters created
|
||||||
// smaller set of objects to check.
|
// smaller set of objects to check.
|
||||||
filterGroup struct {
|
filterGroup struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
fastFilters object.SearchFilters
|
fastFilters object.SearchFilters
|
||||||
slowFilters object.SearchFilters
|
slowFilters object.SearchFilters
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ type (
|
||||||
|
|
||||||
// SelectPrm groups the parameters of Select operation.
|
// SelectPrm groups the parameters of Select operation.
|
||||||
type SelectPrm struct {
|
type SelectPrm struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
filters object.SearchFilters
|
filters object.SearchFilters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ type SelectRes struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContainerID is a Select option to set the container id to search in.
|
// WithContainerID is a Select option to set the container id to search in.
|
||||||
func (p *SelectPrm) WithContainerID(cid *container.ID) *SelectPrm {
|
func (p *SelectPrm) WithContainerID(cid *cid.ID) *SelectPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.cid = cid
|
p.cid = cid
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func (r *SelectRes) AddressList() []*object.Address {
|
||||||
var ErrMissingContainerID = errors.New("missing container id field")
|
var ErrMissingContainerID = errors.New("missing container id field")
|
||||||
|
|
||||||
// Select selects the objects from DB with filtering.
|
// Select selects the objects from DB with filtering.
|
||||||
func Select(db *DB, cid *container.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
func Select(db *DB, cid *cid.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
||||||
r, err := db.Select(new(SelectPrm).WithFilters(fs).WithContainerID(cid))
|
r, err := db.Select(new(SelectPrm).WithFilters(fs).WithContainerID(cid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -84,7 +84,7 @@ func (db *DB) Select(prm *SelectPrm) (res *SelectRes, err error) {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) selectObjects(tx *bbolt.Tx, cid *container.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
func (db *DB) selectObjects(tx *bbolt.Tx, cid *cid.ID, fs object.SearchFilters) ([]*object.Address, error) {
|
||||||
if cid == nil {
|
if cid == nil {
|
||||||
return nil, ErrMissingContainerID
|
return nil, ErrMissingContainerID
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ func (db *DB) selectObjects(tx *bbolt.Tx, cid *container.ID, fs object.SearchFil
|
||||||
}
|
}
|
||||||
|
|
||||||
// selectAll adds to resulting cache all available objects in metabase.
|
// selectAll adds to resulting cache all available objects in metabase.
|
||||||
func (db *DB) selectAll(tx *bbolt.Tx, cid *container.ID, to map[string]int) {
|
func (db *DB) selectAll(tx *bbolt.Tx, cid *cid.ID, to map[string]int) {
|
||||||
prefix := cid.String() + "/"
|
prefix := cid.String() + "/"
|
||||||
|
|
||||||
selectAllFromBucket(tx, primaryBucketName(cid), prefix, to, 0)
|
selectAllFromBucket(tx, primaryBucketName(cid), prefix, to, 0)
|
||||||
|
@ -178,7 +178,7 @@ func selectAllFromBucket(tx *bbolt.Tx, name []byte, prefix string, to map[string
|
||||||
// looking through user attribute buckets otherwise.
|
// looking through user attribute buckets otherwise.
|
||||||
func (db *DB) selectFastFilter(
|
func (db *DB) selectFastFilter(
|
||||||
tx *bbolt.Tx,
|
tx *bbolt.Tx,
|
||||||
cid *container.ID, // container we search on
|
cid *cid.ID, // container we search on
|
||||||
f object.SearchFilter, // fast filter
|
f object.SearchFilter, // fast filter
|
||||||
to map[string]int, // resulting cache
|
to map[string]int, // resulting cache
|
||||||
fNum int, // index of filter
|
fNum int, // index of filter
|
||||||
|
@ -222,13 +222,13 @@ func (db *DB) selectFastFilter(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to DB struct
|
// TODO: move to DB struct
|
||||||
var mBucketNaming = map[string][]func(*container.ID) []byte{
|
var mBucketNaming = map[string][]func(*cid.ID) []byte{
|
||||||
v2object.TypeRegular.String(): {primaryBucketName, parentBucketName},
|
v2object.TypeRegular.String(): {primaryBucketName, parentBucketName},
|
||||||
v2object.TypeTombstone.String(): {tombstoneBucketName},
|
v2object.TypeTombstone.String(): {tombstoneBucketName},
|
||||||
v2object.TypeStorageGroup.String(): {storageGroupBucketName},
|
v2object.TypeStorageGroup.String(): {storageGroupBucketName},
|
||||||
}
|
}
|
||||||
|
|
||||||
func allBucketNames(cid *container.ID) (names [][]byte) {
|
func allBucketNames(cid *cid.ID) (names [][]byte) {
|
||||||
for _, fns := range mBucketNaming {
|
for _, fns := range mBucketNaming {
|
||||||
for _, fn := range fns {
|
for _, fn := range fns {
|
||||||
names = append(names, fn(cid))
|
names = append(names, fn(cid))
|
||||||
|
@ -238,7 +238,7 @@ func allBucketNames(cid *container.ID) (names [][]byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func bucketNamesForType(cid *container.ID, mType object.SearchMatchType, typeVal string) (names [][]byte) {
|
func bucketNamesForType(cid *cid.ID, mType object.SearchMatchType, typeVal string) (names [][]byte) {
|
||||||
appendNames := func(key string) {
|
appendNames := func(key string) {
|
||||||
fns, ok := mBucketNaming[key]
|
fns, ok := mBucketNaming[key]
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -426,7 +426,7 @@ func (db *DB) selectFromList(
|
||||||
func (db *DB) selectObjectID(
|
func (db *DB) selectObjectID(
|
||||||
tx *bbolt.Tx,
|
tx *bbolt.Tx,
|
||||||
f object.SearchFilter,
|
f object.SearchFilter,
|
||||||
cid *container.ID,
|
cid *cid.ID,
|
||||||
to map[string]int, // resulting cache
|
to map[string]int, // resulting cache
|
||||||
fNum int, // index of filter
|
fNum int, // index of filter
|
||||||
) {
|
) {
|
||||||
|
@ -540,7 +540,7 @@ func groupFilters(filters object.SearchFilters) (*filterGroup, error) {
|
||||||
for i := range filters {
|
for i := range filters {
|
||||||
switch filters[i].Header() {
|
switch filters[i].Header() {
|
||||||
case v2object.FilterHeaderContainerID: // support deprecated field
|
case v2object.FilterHeaderContainerID: // support deprecated field
|
||||||
res.cid = container.NewID()
|
res.cid = cid.New()
|
||||||
|
|
||||||
err := res.cid.Parse(filters[i].Value())
|
err := res.cid.Parse(filters[i].Value())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,27 +39,27 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// primaryBucketName returns <CID>.
|
// primaryBucketName returns <CID>.
|
||||||
func primaryBucketName(cid *container.ID) []byte {
|
func primaryBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String())
|
return []byte(cid.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// tombstoneBucketName returns <CID>_TS.
|
// tombstoneBucketName returns <CID>_TS.
|
||||||
func tombstoneBucketName(cid *container.ID) []byte {
|
func tombstoneBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + tombstonePostfix)
|
return []byte(cid.String() + tombstonePostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// storageGroupBucketName returns <CID>_SG.
|
// storageGroupBucketName returns <CID>_SG.
|
||||||
func storageGroupBucketName(cid *container.ID) []byte {
|
func storageGroupBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + storageGroupPostfix)
|
return []byte(cid.String() + storageGroupPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// smallBucketName returns <CID>_small.
|
// smallBucketName returns <CID>_small.
|
||||||
func smallBucketName(cid *container.ID) []byte {
|
func smallBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + smallPostfix) // consider caching output values
|
return []byte(cid.String() + smallPostfix) // consider caching output values
|
||||||
}
|
}
|
||||||
|
|
||||||
// attributeBucketName returns <CID>_attr_<attributeKey>.
|
// attributeBucketName returns <CID>_attr_<attributeKey>.
|
||||||
func attributeBucketName(cid *container.ID, attributeKey string) []byte {
|
func attributeBucketName(cid *cid.ID, attributeKey string) []byte {
|
||||||
sb := strings.Builder{} // consider getting string builders from sync.Pool
|
sb := strings.Builder{} // consider getting string builders from sync.Pool
|
||||||
sb.WriteString(cid.String())
|
sb.WriteString(cid.String())
|
||||||
sb.WriteString(userAttributePostfix)
|
sb.WriteString(userAttributePostfix)
|
||||||
|
@ -79,27 +79,27 @@ func cidFromAttributeBucket(val []byte, attributeKey string) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// payloadHashBucketName returns <CID>_payloadhash.
|
// payloadHashBucketName returns <CID>_payloadhash.
|
||||||
func payloadHashBucketName(cid *container.ID) []byte {
|
func payloadHashBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + payloadHashPostfix)
|
return []byte(cid.String() + payloadHashPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rootBucketName returns <CID>_root.
|
// rootBucketName returns <CID>_root.
|
||||||
func rootBucketName(cid *container.ID) []byte {
|
func rootBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + rootPostfix)
|
return []byte(cid.String() + rootPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ownerBucketName returns <CID>_ownerid.
|
// ownerBucketName returns <CID>_ownerid.
|
||||||
func ownerBucketName(cid *container.ID) []byte {
|
func ownerBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + ownerPostfix)
|
return []byte(cid.String() + ownerPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parentBucketName returns <CID>_parent.
|
// parentBucketName returns <CID>_parent.
|
||||||
func parentBucketName(cid *container.ID) []byte {
|
func parentBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + parentPostfix)
|
return []byte(cid.String() + parentPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// splitBucketName returns <CID>_splitid.
|
// splitBucketName returns <CID>_splitid.
|
||||||
func splitBucketName(cid *container.ID) []byte {
|
func splitBucketName(cid *cid.ID) []byte {
|
||||||
return []byte(cid.String() + splitPostfix)
|
return []byte(cid.String() + splitPostfix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,18 @@ package shard
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerSizePrm struct {
|
type ContainerSizePrm struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerSizeRes struct {
|
type ContainerSizeRes struct {
|
||||||
size uint64
|
size uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ContainerSizePrm) WithContainerID(cid *container.ID) *ContainerSizePrm {
|
func (p *ContainerSizePrm) WithContainerID(cid *cid.ID) *ContainerSizePrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.cid = cid
|
p.cid = cid
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (s *Shard) ContainerSize(prm *ContainerSizePrm) (*ContainerSizeRes, error)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContainerSize(s *Shard, cid *container.ID) (uint64, error) {
|
func ContainerSize(s *Shard, cid *cid.ID) (uint64, error) {
|
||||||
res, err := s.ContainerSize(&ContainerSizePrm{cid: cid})
|
res, err := s.ContainerSize(&ContainerSizePrm{cid: cid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
|
@ -3,7 +3,7 @@ package shard
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -12,10 +12,10 @@ import (
|
||||||
type ListContainersPrm struct{}
|
type ListContainersPrm struct{}
|
||||||
|
|
||||||
type ListContainersRes struct {
|
type ListContainersRes struct {
|
||||||
containers []*container.ID
|
containers []*cid.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ListContainersRes) Containers() []*container.ID {
|
func (r *ListContainersRes) Containers() []*cid.ID {
|
||||||
return r.containers
|
return r.containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func (s *Shard) ListContainers(_ *ListContainersPrm) (*ListContainersRes, error)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListContainers(s *Shard) ([]*container.ID, error) {
|
func ListContainers(s *Shard) ([]*cid.ID, error) {
|
||||||
res, err := s.ListContainers(&ListContainersPrm{})
|
res, err := s.ListContainers(&ListContainersPrm{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -3,14 +3,14 @@ package shard
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SelectPrm groups the parameters of Select operation.
|
// SelectPrm groups the parameters of Select operation.
|
||||||
type SelectPrm struct {
|
type SelectPrm struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
filters objectSDK.SearchFilters
|
filters objectSDK.SearchFilters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ type SelectRes struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContainerID is a Select option to set the container id to search in.
|
// WithContainerID is a Select option to set the container id to search in.
|
||||||
func (p *SelectPrm) WithContainerID(cid *container.ID) *SelectPrm {
|
func (p *SelectPrm) WithContainerID(cid *cid.ID) *SelectPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.cid = cid
|
p.cid = cid
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -64,7 +64,7 @@ func generateRawObject(t *testing.T) *object.RawObject {
|
||||||
return generateRawObjectWithCID(t, generateCID())
|
return generateRawObjectWithCID(t, generateCID())
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRawObjectWithCID(t *testing.T, cid *container.ID) *object.RawObject {
|
func generateRawObjectWithCID(t *testing.T, cid *cid.ID) *object.RawObject {
|
||||||
version := pkg.NewVersion()
|
version := pkg.NewVersion()
|
||||||
version.SetMajor(2)
|
version.SetMajor(2)
|
||||||
version.SetMinor(1)
|
version.SetMinor(1)
|
||||||
|
@ -110,11 +110,11 @@ func addPayload(obj *object.RawObject, size int) {
|
||||||
obj.SetPayloadSize(uint64(size))
|
obj.SetPayloadSize(uint64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCID() *container.ID {
|
func generateCID() *cid.ID {
|
||||||
cs := [sha256.Size]byte{}
|
cs := [sha256.Size]byte{}
|
||||||
_, _ = rand.Read(cs[:])
|
_, _ = rand.Read(cs[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(cs)
|
id.SetSHA256(cs)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||||
"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-node/pkg/morph/client/audit"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ func (w *ClientWrapper) ListAuditResultIDByEpoch(epoch uint64) ([]ResultID, erro
|
||||||
|
|
||||||
// ListAuditResultIDByCID returns a list of audit result IDs inside audit
|
// ListAuditResultIDByCID returns a list of audit result IDs inside audit
|
||||||
// contract for specific epoch number and container ID.
|
// contract for specific epoch number and container ID.
|
||||||
func (w *ClientWrapper) ListAuditResultIDByCID(epoch uint64, cid *container.ID) ([]ResultID, error) {
|
func (w *ClientWrapper) ListAuditResultIDByCID(epoch uint64, cid *cid.ID) ([]ResultID, error) {
|
||||||
args := audit.ListResultsByCIDArgs{}
|
args := audit.ListResultsByCIDArgs{}
|
||||||
args.SetEpoch(int64(epoch))
|
args.SetEpoch(int64(epoch))
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ func (w *ClientWrapper) ListAuditResultIDByCID(epoch uint64, cid *container.ID)
|
||||||
|
|
||||||
// ListAuditResultIDByNode returns a list of audit result IDs inside audit
|
// ListAuditResultIDByNode returns a list of audit result IDs inside audit
|
||||||
// contract for specific epoch number, container ID and inner ring public key.
|
// contract for specific epoch number, container ID and inner ring public key.
|
||||||
func (w *ClientWrapper) ListAuditResultIDByNode(epoch uint64, cid *container.ID, key []byte) ([]ResultID, error) {
|
func (w *ClientWrapper) ListAuditResultIDByNode(epoch uint64, cid *cid.ID, key []byte) ([]ResultID, error) {
|
||||||
args := audit.ListResultsByNodeArgs{}
|
args := audit.ListResultsByNodeArgs{}
|
||||||
args.SetEpoch(int64(epoch))
|
args.SetEpoch(int64(epoch))
|
||||||
args.SetNodeKey(key)
|
args.SetNodeKey(key)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
||||||
|
@ -36,19 +36,19 @@ func TestAuditResults(t *testing.T) {
|
||||||
auditClientWrapper, err := auditWrapper.NewFromMorph(morphClient, auditHash, 0)
|
auditClientWrapper, err := auditWrapper.NewFromMorph(morphClient, auditHash, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256([sha256.Size]byte{1, 2, 3})
|
id.SetSHA256([sha256.Size]byte{1, 2, 3})
|
||||||
|
|
||||||
auditRes := auditAPI.NewResult()
|
auditRes := auditAPI.NewResult()
|
||||||
auditRes.SetAuditEpoch(epoch)
|
auditRes.SetAuditEpoch(epoch)
|
||||||
auditRes.SetPublicKey(pubKey)
|
auditRes.SetPublicKey(pubKey)
|
||||||
auditRes.SetContainerID(cid)
|
auditRes.SetContainerID(id)
|
||||||
|
|
||||||
require.NoError(t, auditClientWrapper.PutAuditResult(auditRes))
|
require.NoError(t, auditClientWrapper.PutAuditResult(auditRes))
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, cid)
|
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, list, 1)
|
require.Len(t, list, 1)
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (w *Wrapper) Put(cnr, key, sig, token []byte) error {
|
||||||
|
|
||||||
type containerSource Wrapper
|
type containerSource Wrapper
|
||||||
|
|
||||||
func (x *containerSource) Get(cid *container.ID) (*container.Container, error) {
|
func (x *containerSource) Get(cid *cid.ID) (*container.Container, error) {
|
||||||
return Get((*Wrapper)(x), cid)
|
return Get((*Wrapper)(x), cid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ func AsContainerSource(w *Wrapper) core.Source {
|
||||||
// Get marshals container ID, and passes it to Wrapper's Get method.
|
// Get marshals container ID, and passes it to Wrapper's Get method.
|
||||||
//
|
//
|
||||||
// Returns error if cid is nil.
|
// Returns error if cid is nil.
|
||||||
func Get(w *Wrapper, cid *container.ID) (*container.Container, error) {
|
func Get(w *Wrapper, cid *cid.ID) (*container.Container, error) {
|
||||||
return w.Get(cid.ToV2().GetValue())
|
return w.Get(cid.ToV2().GetValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ func (w *Wrapper) Delete(cid, signature, token []byte) error {
|
||||||
//
|
//
|
||||||
// Returns the identifiers of all NeoFS containers if pointer
|
// Returns the identifiers of all NeoFS containers if pointer
|
||||||
// to owner identifier is nil.
|
// to owner identifier is nil.
|
||||||
func (w *Wrapper) List(ownerID *owner.ID) ([]*container.ID, error) {
|
func (w *Wrapper) List(ownerID *owner.ID) ([]*cid.ID, error) {
|
||||||
args := client.ListArgs{}
|
args := client.ListArgs{}
|
||||||
|
|
||||||
if ownerID == nil {
|
if ownerID == nil {
|
||||||
|
@ -212,15 +212,15 @@ func (w *Wrapper) List(ownerID *owner.ID) ([]*container.ID, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rawIDs := rpcAnswer.CIDList()
|
rawIDs := rpcAnswer.CIDList()
|
||||||
result := make([]*container.ID, 0, len(rawIDs))
|
result := make([]*cid.ID, 0, len(rawIDs))
|
||||||
|
|
||||||
for i := range rawIDs {
|
for i := range rawIDs {
|
||||||
v2 := new(v2refs.ContainerID)
|
v2 := new(v2refs.ContainerID)
|
||||||
v2.SetValue(rawIDs[i])
|
v2.SetValue(rawIDs[i])
|
||||||
|
|
||||||
cid := container.NewIDFromV2(v2)
|
id := cid.NewFromV2(v2)
|
||||||
|
|
||||||
result = append(result, cid)
|
result = append(result, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
@ -280,7 +280,7 @@ type Estimation struct {
|
||||||
|
|
||||||
// Estimation is a structure of grouped container load estimation inside Container contract.
|
// Estimation is a structure of grouped container load estimation inside Container contract.
|
||||||
type Estimations struct {
|
type Estimations struct {
|
||||||
ContainerID *container.ID
|
ContainerID *cid.ID
|
||||||
|
|
||||||
Values []Estimation
|
Values []Estimation
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ func (w *Wrapper) GetUsedSpaceEstimations(id EstimationID) (*Estimations, error)
|
||||||
v2.SetValue(es.ContainerID)
|
v2.SetValue(es.ContainerID)
|
||||||
|
|
||||||
res := &Estimations{
|
res := &Estimations{
|
||||||
ContainerID: container.NewIDFromV2(v2),
|
ContainerID: cid.NewFromV2(v2),
|
||||||
Values: make([]Estimation, 0, len(es.Estimations)),
|
Values: make([]Estimation, 0, len(es.Estimations)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/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/storagegroup"
|
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
||||||
|
@ -150,7 +150,7 @@ func (c *Context) WithPoRWorkerPool(pool util.WorkerPool) *Context {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) containerID() *container.ID {
|
func (c *Context) containerID() *cid.ID {
|
||||||
return c.task.ContainerID()
|
return c.task.ContainerID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ type Reporter interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewReport creates and returns blank Report instance.
|
// NewReport creates and returns blank Report instance.
|
||||||
func NewReport(cid *container.ID) *Report {
|
func NewReport(cid *cid.ID) *Report {
|
||||||
rep := &Report{
|
rep := &Report{
|
||||||
res: audit.NewResult(),
|
res: audit.NewResult(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"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/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"
|
||||||
)
|
)
|
||||||
|
@ -14,7 +15,7 @@ type Task struct {
|
||||||
|
|
||||||
auditContext context.Context
|
auditContext context.Context
|
||||||
|
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
|
|
||||||
cnr *container.Container
|
cnr *container.Container
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ func (t *Task) AuditContext() context.Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContainerID sets identifier of the container under audit.
|
// WithContainerID sets identifier of the container under audit.
|
||||||
func (t *Task) WithContainerID(cid *container.ID) *Task {
|
func (t *Task) WithContainerID(cid *cid.ID) *Task {
|
||||||
if t != nil {
|
if t != nil {
|
||||||
t.cid = cid
|
t.cid = cid
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,7 @@ func (t *Task) WithContainerID(cid *container.ID) *Task {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerID returns identifier of the container under audit.
|
// ContainerID returns identifier of the container under audit.
|
||||||
func (t *Task) ContainerID() *container.ID {
|
func (t *Task) ContainerID() *cid.ID {
|
||||||
return t.cid
|
return t.cid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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"
|
||||||
loadcontroller "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/controller"
|
loadcontroller "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/controller"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -73,12 +74,12 @@ func (s *testAnnouncementStorage) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func randCID() *container.ID {
|
func randCID() *cid.ID {
|
||||||
h := [sha256.Size]byte{}
|
h := [sha256.Size]byte{}
|
||||||
|
|
||||||
rand.Read(h[:])
|
rand.Read(h[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(h)
|
id.SetSHA256(h)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package placementrouter
|
package placementrouter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"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/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,5 +10,5 @@ type PlacementBuilder interface {
|
||||||
// BuildPlacement must compose and sort (according to a specific algorithm)
|
// BuildPlacement must compose and sort (according to a specific algorithm)
|
||||||
// storage nodes from the container with identifier cid using network map
|
// storage nodes from the container with identifier cid using network map
|
||||||
// of particular epoch.
|
// of particular epoch.
|
||||||
BuildPlacement(epoch uint64, cid *container.ID) ([]netmap.Nodes, error)
|
BuildPlacement(epoch uint64, cid *cid.ID) ([]netmap.Nodes, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,16 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func randCID() *container.ID {
|
func randCID() *cid.ID {
|
||||||
h := [sha256.Size]byte{}
|
h := [sha256.Size]byte{}
|
||||||
|
|
||||||
rand.Read(h[:])
|
rand.Read(h[:])
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(h)
|
id.SetSHA256(h)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"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"
|
||||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
containerSDK "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"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||||
|
@ -52,13 +53,13 @@ func (s *morphExecutor) Put(ctx containerSvc.ContextWithToken, body *container.P
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) Delete(ctx containerSvc.ContextWithToken, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) {
|
func (s *morphExecutor) Delete(ctx containerSvc.ContextWithToken, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) {
|
||||||
cid := containerSDK.NewIDFromV2(body.GetContainerID())
|
id := cid.NewFromV2(body.GetContainerID())
|
||||||
sig := body.GetSignature().GetSign()
|
sig := body.GetSignature().GetSign()
|
||||||
tok := session.NewTokenFromV2(ctx.SessionToken)
|
tok := session.NewTokenFromV2(ctx.SessionToken)
|
||||||
|
|
||||||
var rmWitness containercore.RemovalWitness
|
var rmWitness containercore.RemovalWitness
|
||||||
|
|
||||||
rmWitness.SetContainerID(cid)
|
rmWitness.SetContainerID(id)
|
||||||
rmWitness.SetSignature(sig)
|
rmWitness.SetSignature(sig)
|
||||||
rmWitness.SetSessionToken(tok)
|
rmWitness.SetSessionToken(tok)
|
||||||
|
|
||||||
|
@ -71,9 +72,9 @@ func (s *morphExecutor) Delete(ctx containerSvc.ContextWithToken, body *containe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) Get(ctx context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
|
func (s *morphExecutor) Get(ctx context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
|
||||||
cid := containerSDK.NewIDFromV2(body.GetContainerID())
|
id := cid.NewFromV2(body.GetContainerID())
|
||||||
|
|
||||||
cnr, err := wrapper.Get(s.wrapper, cid)
|
cnr, err := wrapper.Get(s.wrapper, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -121,9 +122,9 @@ func (s *morphExecutor) SetExtendedACL(ctx containerSvc.ContextWithToken, body *
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *morphExecutor) GetExtendedACL(ctx context.Context, body *container.GetExtendedACLRequestBody) (*container.GetExtendedACLResponseBody, error) {
|
func (s *morphExecutor) GetExtendedACL(ctx context.Context, body *container.GetExtendedACLRequestBody) (*container.GetExtendedACLResponseBody, error) {
|
||||||
cid := containerSDK.NewIDFromV2(body.GetContainerID())
|
id := cid.NewFromV2(body.GetContainerID())
|
||||||
|
|
||||||
table, err := s.wrapper.GetEACL(cid)
|
table, err := s.wrapper.GetEACL(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
acl "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
acl "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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/util/signature"
|
"github.com/nspcc-dev/neofs-api-go/util/signature"
|
||||||
|
@ -69,7 +69,7 @@ type (
|
||||||
operation acl.Operation // put, get, head, etc.
|
operation acl.Operation // put, get, head, etc.
|
||||||
cnrOwner *owner.ID // container owner
|
cnrOwner *owner.ID // container owner
|
||||||
|
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
|
|
||||||
oid *objectSDK.ID
|
oid *objectSDK.ID
|
||||||
|
|
||||||
|
@ -225,9 +225,9 @@ func (b Service) Head(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Service) Search(request *object.SearchRequest, stream objectSvc.SearchStream) error {
|
func (b Service) Search(request *object.SearchRequest, stream objectSvc.SearchStream) error {
|
||||||
var cid *container.ID
|
var id *cid.ID
|
||||||
|
|
||||||
cid, err := getContainerIDFromRequest(request)
|
id, err := getContainerIDFromRequest(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ func (b Service) Search(request *object.SearchRequest, stream objectSvc.SearchSt
|
||||||
src: request,
|
src: request,
|
||||||
}
|
}
|
||||||
|
|
||||||
reqInfo, err := b.findRequestInfo(req, cid, acl.OperationSearch)
|
reqInfo, err := b.findRequestInfo(req, id, acl.OperationSearch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ func (g *searchStreamBasicChecker) Send(resp *object.SearchResponse) error {
|
||||||
|
|
||||||
func (b Service) findRequestInfo(
|
func (b Service) findRequestInfo(
|
||||||
req metaWithToken,
|
req metaWithToken,
|
||||||
cid *container.ID,
|
cid *cid.ID,
|
||||||
op acl.Operation) (info requestInfo, err error) {
|
op acl.Operation) (info requestInfo, err error) {
|
||||||
cnr, err := b.containers.Get(cid) // fetch actual container
|
cnr, err := b.containers.Get(cid) // fetch actual container
|
||||||
if err != nil || cnr.OwnerID() == nil {
|
if err != nil || cnr.OwnerID() == nil {
|
||||||
|
@ -480,27 +480,27 @@ func (b Service) findRequestInfo(
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContainerIDFromRequest(req interface{}) (id *container.ID, err error) {
|
func getContainerIDFromRequest(req interface{}) (id *cid.ID, err error) {
|
||||||
switch v := req.(type) {
|
switch v := req.(type) {
|
||||||
case *object.GetRequest:
|
case *object.GetRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
case *object.PutRequest:
|
case *object.PutRequest:
|
||||||
objPart := v.GetBody().GetObjectPart()
|
objPart := v.GetBody().GetObjectPart()
|
||||||
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
if part, ok := objPart.(*object.PutObjectPartInit); ok {
|
||||||
return container.NewIDFromV2(part.GetHeader().GetContainerID()), nil
|
return cid.NewFromV2(part.GetHeader().GetContainerID()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("can't get cid in chunk")
|
return nil, errors.New("can't get cid in chunk")
|
||||||
case *object.HeadRequest:
|
case *object.HeadRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
case *object.SearchRequest:
|
case *object.SearchRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetContainerID()), nil
|
||||||
case *object.DeleteRequest:
|
case *object.DeleteRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
case *object.GetRangeRequest:
|
case *object.GetRangeRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
case *object.GetRangeHashRequest:
|
case *object.GetRangeHashRequest:
|
||||||
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknown request type")
|
return nil, errors.New("unknown request type")
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||||
acl "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
acl "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"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/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
"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/util/signature"
|
"github.com/nspcc-dev/neofs-api-go/util/signature"
|
||||||
|
@ -49,7 +50,7 @@ func NewSenderClassifier(l *zap.Logger, ir InnerRingFetcher, nm core.Source) Sen
|
||||||
|
|
||||||
func (c SenderClassifier) Classify(
|
func (c SenderClassifier) Classify(
|
||||||
req metaWithToken,
|
req metaWithToken,
|
||||||
cid *container.ID,
|
cid *cid.ID,
|
||||||
cnr *container.Container) (role acl.Role, isIR bool, key []byte, err error) {
|
cnr *container.Container) (role acl.Role, isIR bool, key []byte, err error) {
|
||||||
if cid == nil {
|
if cid == nil {
|
||||||
return 0, false, nil, fmt.Errorf("%w: container id is not set", ErrMalformedRequest)
|
return 0, false, nil, fmt.Errorf("%w: container id is not set", ErrMalformedRequest)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eacl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
bearer "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
bearer "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ type Storage interface {
|
||||||
//
|
//
|
||||||
// Must return pkg/core/container.ErrEACLNotFound if requested
|
// Must return pkg/core/container.ErrEACLNotFound if requested
|
||||||
// eACL table is is not in storage.
|
// eACL table is is not in storage.
|
||||||
GetEACL(*container.ID) (*eacl.Table, error)
|
GetEACL(*cid.ID) (*eacl.Table, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header is an interface of string key-value header.
|
// Header is an interface of string key-value header.
|
||||||
|
@ -38,7 +38,7 @@ type TypedHeaderSource interface {
|
||||||
|
|
||||||
// ValidationUnit represents unit of check for Validator.
|
// ValidationUnit represents unit of check for Validator.
|
||||||
type ValidationUnit struct {
|
type ValidationUnit struct {
|
||||||
cid *container.ID
|
cid *cid.ID
|
||||||
|
|
||||||
role eacl.Role
|
role eacl.Role
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ type ValidationUnit struct {
|
||||||
bearer *bearer.BearerToken
|
bearer *bearer.BearerToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ValidationUnit) WithContainerID(v *container.ID) *ValidationUnit {
|
func (u *ValidationUnit) WithContainerID(v *cid.ID) *ValidationUnit {
|
||||||
if u != nil {
|
if u != nil {
|
||||||
u.cid = v
|
u.cid = v
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
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"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
|
@ -28,12 +28,12 @@ type testLocalStorage struct {
|
||||||
type testEACLStorage struct {
|
type testEACLStorage struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
|
|
||||||
expCID *container.ID
|
expCID *cid.ID
|
||||||
|
|
||||||
table *eacl.Table
|
table *eacl.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testEACLStorage) GetEACL(id *container.ID) (*eacl.Table, error) {
|
func (s *testEACLStorage) GetEACL(id *cid.ID) (*eacl.Table, error) {
|
||||||
require.True(s.t, s.expCID.Equal(id))
|
require.True(s.t, s.expCID.Equal(id))
|
||||||
|
|
||||||
return s.table, nil
|
return s.table, nil
|
||||||
|
@ -57,13 +57,13 @@ func testID(t *testing.T) *objectSDK.ID {
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCID(t *testing.T) *container.ID {
|
func testCID(t *testing.T) *cid.ID {
|
||||||
cs := [sha256.Size]byte{}
|
cs := [sha256.Size]byte{}
|
||||||
|
|
||||||
_, err := rand.Read(cs[:])
|
_, err := rand.Read(cs[:])
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
id := container.NewID()
|
id := cid.New()
|
||||||
id.SetSHA256(cs)
|
id.SetSHA256(cs)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"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"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
|
@ -110,7 +110,7 @@ func (h *headerSource) objectHeaders() ([]eacl.Header, bool) {
|
||||||
|
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
addr = objectSDK.NewAddress()
|
addr = objectSDK.NewAddress()
|
||||||
addr.SetContainerID(container.NewIDFromV2(v.GetHeader().GetContainerID()))
|
addr.SetContainerID(cid.NewFromV2(v.GetHeader().GetContainerID()))
|
||||||
addr.SetObjectID(objectSDK.NewIDFromV2(v.GetObjectID()))
|
addr.SetObjectID(objectSDK.NewIDFromV2(v.GetObjectID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ func (h *headerSource) objectHeaders() ([]eacl.Header, bool) {
|
||||||
}
|
}
|
||||||
case *objectV2.SearchRequest:
|
case *objectV2.SearchRequest:
|
||||||
return []eacl.Header{cidHeader(
|
return []eacl.Header{cidHeader(
|
||||||
container.NewIDFromV2(
|
cid.NewFromV2(
|
||||||
req.GetBody().GetContainerID()),
|
req.GetBody().GetContainerID()),
|
||||||
)}, true
|
)}, true
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func (h *headerSource) localObjectHeaders(addrV2 *refs.Address) ([]eacl.Header,
|
||||||
return addressHeaders(addr), false
|
return addressHeaders(addr), false
|
||||||
}
|
}
|
||||||
|
|
||||||
func cidHeader(cid *container.ID) eacl.Header {
|
func cidHeader(cid *cid.ID) eacl.Header {
|
||||||
return &sysObjHdr{
|
return &sysObjHdr{
|
||||||
k: acl.FilterObjectContainerID,
|
k: acl.FilterObjectContainerID,
|
||||||
v: cidValue(cid),
|
v: cidValue(cid),
|
||||||
|
|
|
@ -3,7 +3,7 @@ package v2
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "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/v2/acl"
|
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
|
@ -27,7 +27,7 @@ func idValue(id *objectSDK.ID) string {
|
||||||
return id.String()
|
return id.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func cidValue(id *container.ID) string {
|
func cidValue(id *cid.ID) string {
|
||||||
return id.String()
|
return id.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
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"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -63,7 +63,7 @@ func (exec *execCtx) address() *objectSDK.Address {
|
||||||
return exec.prm.Address()
|
return exec.prm.Address()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) containerID() *container.ID {
|
func (exec *execCtx) containerID() *cid.ID {
|
||||||
return exec.prm.Address().ContainerID()
|
return exec.prm.Address().ContainerID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package deletesvc
|
||||||
|
|
||||||
import (
|
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/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
|
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||||
|
@ -15,7 +15,7 @@ type tombstoneBodyWriter struct {
|
||||||
func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteResponseBody) (*deletesvc.Prm, error) {
|
func (s *Service) toPrm(req *objectV2.DeleteRequest, respBody *objectV2.DeleteResponseBody) (*deletesvc.Prm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(session.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
|
@ -134,7 +134,7 @@ func (exec *execCtx) splitInfo() *objectSDK.SplitInfo {
|
||||||
return exec.infoSplit
|
return exec.infoSplit
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) containerID() *container.ID {
|
func (exec *execCtx) containerID() *cid.ID {
|
||||||
return exec.address().ContainerID()
|
return exec.address().ContainerID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -191,10 +192,10 @@ func generateAddress() *objectSDK.Address {
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetObjectID(generateID())
|
addr.SetObjectID(generateID())
|
||||||
|
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256(testSHA256())
|
id.SetSHA256(testSHA256())
|
||||||
|
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(id)
|
||||||
|
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
@ -432,7 +433,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) {
|
||||||
return mNodes, mAddr
|
return mNodes, mAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateChain(ln int, cid *container.ID) ([]*object.RawObject, []*objectSDK.ID, []byte) {
|
func generateChain(ln int, cid *cid.ID) ([]*object.RawObject, []*objectSDK.ID, []byte) {
|
||||||
curID := generateID()
|
curID := generateID()
|
||||||
var prevID *objectSDK.ID
|
var prevID *objectSDK.ID
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
sessionsdk "github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
rpcclient "github.com/nspcc-dev/neofs-api-go/rpc/client"
|
rpcclient "github.com/nspcc-dev/neofs-api-go/rpc/client"
|
||||||
signature2 "github.com/nspcc-dev/neofs-api-go/util/signature"
|
signature2 "github.com/nspcc-dev/neofs-api-go/util/signature"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
|
@ -31,7 +31,7 @@ var errWrongMessageSeq = errors.New("incorrect message sequence")
|
||||||
func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStream) (*getsvc.Prm, error) {
|
func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStream) (*getsvc.Prm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
|
||||||
func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.GetObjectRangeStream) (*getsvc.RangePrm, error) {
|
func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.GetObjectRangeStream) (*getsvc.RangePrm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
|
||||||
func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.RangeHashPrm, error) {
|
func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.RangeHashPrm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ func (w *headResponseWriter) WriteHeader(hdr *object.Object) error {
|
||||||
func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp *objectV2.HeadResponse) (*getsvc.HeadPrm, error) {
|
func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp *objectV2.HeadResponse) (*getsvc.HeadPrm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package searchsvc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
||||||
|
@ -59,7 +59,7 @@ func (exec execCtx) isLocal() bool {
|
||||||
return exec.prm.common.LocalOnly()
|
return exec.prm.common.LocalOnly()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) containerID() *container.ID {
|
func (exec *execCtx) containerID() *cid.ID {
|
||||||
return exec.prm.ContainerID()
|
return exec.prm.ContainerID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func (exec *execCtx) initEpoch() bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) generateTraverser(cid *container.ID) (*placement.Traverser, bool) {
|
func (exec *execCtx) generateTraverser(cid *cid.ID) (*placement.Traverser, bool) {
|
||||||
t, err := exec.svc.traverserGenerator.generateTraverser(cid, exec.curProcEpoch)
|
t, err := exec.svc.traverserGenerator.generateTraverser(cid, exec.curProcEpoch)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
|
@ -62,7 +63,7 @@ func newTestStorage() *testStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *testTraverserGenerator) generateTraverser(_ *container.ID, epoch uint64) (*placement.Traverser, error) {
|
func (g *testTraverserGenerator) generateTraverser(_ *cid.ID, epoch uint64) (*placement.Traverser, error) {
|
||||||
return placement.NewTraverser(
|
return placement.NewTraverser(
|
||||||
placement.ForContainer(g.c),
|
placement.ForContainer(g.c),
|
||||||
placement.UseBuilder(g.b[epoch]),
|
placement.UseBuilder(g.b[epoch]),
|
||||||
|
@ -114,7 +115,7 @@ func (c *testStorage) searchObjects(exec *execCtx) ([]*objectSDK.ID, error) {
|
||||||
return v.ids, v.err
|
return v.ids, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testStorage) addResult(addr *container.ID, ids []*objectSDK.ID, err error) {
|
func (c *testStorage) addResult(addr *cid.ID, ids []*objectSDK.ID, err error) {
|
||||||
c.items[addr.String()] = idsErr{
|
c.items[addr.String()] = idsErr{
|
||||||
ids: ids,
|
ids: ids,
|
||||||
err: err,
|
err: err,
|
||||||
|
@ -126,11 +127,11 @@ func testSHA256() (cs [sha256.Size]byte) {
|
||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCID() *container.ID {
|
func generateCID() *cid.ID {
|
||||||
cid := container.NewID()
|
id := cid.New()
|
||||||
cid.SetSHA256(testSHA256())
|
id.SetSHA256(testSHA256())
|
||||||
|
|
||||||
return cid
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateIDs(num int) []*objectSDK.ID {
|
func generateIDs(num int) []*objectSDK.ID {
|
||||||
|
@ -155,7 +156,7 @@ func TestGetLocalOnly(t *testing.T) {
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
|
||||||
newPrm := func(cid *container.ID, w IDListWriter) Prm {
|
newPrm := func(cid *cid.ID, w IDListWriter) Prm {
|
||||||
p := Prm{}
|
p := Prm{}
|
||||||
p.WithContainerID(cid)
|
p.WithContainerID(cid)
|
||||||
p.SetWriter(w)
|
p.SetWriter(w)
|
||||||
|
@ -247,7 +248,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
pp.SetReplicas(rs...)
|
pp.SetReplicas(rs...)
|
||||||
|
|
||||||
cnr := container.New(container.WithPolicy(pp))
|
cnr := container.New(container.WithPolicy(pp))
|
||||||
cid := container.CalculateID(cnr)
|
id := container.CalculateID(cnr)
|
||||||
|
|
||||||
newSvc := func(b *testPlacementBuilder, c *testClientCache) *Service {
|
newSvc := func(b *testPlacementBuilder, c *testClientCache) *Service {
|
||||||
svc := &Service{cfg: new(cfg)}
|
svc := &Service{cfg: new(cfg)}
|
||||||
|
@ -268,9 +269,9 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
|
||||||
newPrm := func(cid *container.ID, w IDListWriter) Prm {
|
newPrm := func(id *cid.ID, w IDListWriter) Prm {
|
||||||
p := Prm{}
|
p := Prm{}
|
||||||
p.WithContainerID(cid)
|
p.WithContainerID(id)
|
||||||
p.SetWriter(w)
|
p.SetWriter(w)
|
||||||
p.common = new(util.CommonPrm).WithLocalOnly(false)
|
p.common = new(util.CommonPrm).WithLocalOnly(false)
|
||||||
|
|
||||||
|
@ -279,7 +280,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
t.Run("OK", func(t *testing.T) {
|
t.Run("OK", func(t *testing.T) {
|
||||||
addr := objectSDK.NewAddress()
|
addr := objectSDK.NewAddress()
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(id)
|
||||||
|
|
||||||
ns, as := testNodeMatrix(t, placementDim)
|
ns, as := testNodeMatrix(t, placementDim)
|
||||||
|
|
||||||
|
@ -291,11 +292,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
c1 := newTestStorage()
|
c1 := newTestStorage()
|
||||||
ids1 := generateIDs(10)
|
ids1 := generateIDs(10)
|
||||||
c1.addResult(cid, ids1, nil)
|
c1.addResult(id, ids1, nil)
|
||||||
|
|
||||||
c2 := newTestStorage()
|
c2 := newTestStorage()
|
||||||
ids2 := generateIDs(10)
|
ids2 := generateIDs(10)
|
||||||
c2.addResult(cid, ids2, nil)
|
c2.addResult(id, ids2, nil)
|
||||||
|
|
||||||
svc := newSvc(builder, &testClientCache{
|
svc := newSvc(builder, &testClientCache{
|
||||||
clients: map[string]*testStorage{
|
clients: map[string]*testStorage{
|
||||||
|
@ -306,7 +307,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
w := new(simpleIDWriter)
|
w := new(simpleIDWriter)
|
||||||
|
|
||||||
p := newPrm(cid, w)
|
p := newPrm(id, w)
|
||||||
|
|
||||||
err := svc.Search(ctx, p)
|
err := svc.Search(ctx, p)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package searchsvc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"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/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
||||||
|
@ -42,7 +42,7 @@ type cfg struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
traverserGenerator interface {
|
traverserGenerator interface {
|
||||||
generateTraverser(*container.ID, uint64) (*placement.Traverser, error)
|
generateTraverser(*cid.ID, uint64) (*placement.Traverser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEpochReceiver interface {
|
currentEpochReceiver interface {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
||||||
|
@ -111,7 +111,7 @@ func idsFromAddresses(addrs []*objectSDK.Address) []*objectSDK.ID {
|
||||||
return ids
|
return ids
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *traverseGeneratorWrapper) generateTraverser(cid *container.ID, epoch uint64) (*placement.Traverser, error) {
|
func (e *traverseGeneratorWrapper) generateTraverser(cid *cid.ID, epoch uint64) (*placement.Traverser, error) {
|
||||||
a := objectSDK.NewAddress()
|
a := objectSDK.NewAddress()
|
||||||
a.SetContainerID(cid)
|
a.SetContainerID(cid)
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
sessionsdk "github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
rpcclient "github.com/nspcc-dev/neofs-api-go/rpc/client"
|
rpcclient "github.com/nspcc-dev/neofs-api-go/rpc/client"
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc"
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc"
|
||||||
|
@ -23,7 +23,7 @@ import (
|
||||||
func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStream) (*searchsvc.Prm, error) {
|
func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStream) (*searchsvc.Prm, error) {
|
||||||
meta := req.GetMetaHeader()
|
meta := req.GetMetaHeader()
|
||||||
|
|
||||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
||||||
}
|
}
|
||||||
|
|
||||||
body := req.GetBody()
|
body := req.GetBody()
|
||||||
p.WithContainerID(container.NewIDFromV2(body.GetContainerID()))
|
p.WithContainerID(cid.NewFromV2(body.GetContainerID()))
|
||||||
p.WithSearchFilters(objectSDK.NewSearchFiltersFromV2(body.GetFilters()))
|
p.WithSearchFilters(objectSDK.NewSearchFiltersFromV2(body.GetFilters()))
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
|
|
|
@ -3,7 +3,7 @@ package util
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func NewKeyStorage(localKey *ecdsa.PrivateKey, tokenStore *storage.TokenStore) *
|
||||||
//
|
//
|
||||||
// If token is not nil, session private key is returned.
|
// If token is not nil, session private key is returned.
|
||||||
// Otherwise, node private key is returned.
|
// Otherwise, node private key is returned.
|
||||||
func (s *KeyStorage) GetKey(token *token.SessionToken) (*ecdsa.PrivateKey, error) {
|
func (s *KeyStorage) GetKey(token *session.Token) (*ecdsa.PrivateKey, error) {
|
||||||
if token != nil {
|
if token != nil {
|
||||||
pToken := s.tokenStore.Get(token.OwnerID(), token.ID())
|
pToken := s.tokenStore.Get(token.OwnerID(), token.ID())
|
||||||
if pToken != nil {
|
if pToken != nil {
|
||||||
|
|
|
@ -6,6 +6,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/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
|
sessionsdk "github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
)
|
)
|
||||||
|
@ -15,7 +16,7 @@ type CommonPrm struct {
|
||||||
|
|
||||||
netmapEpoch, netmapLookupDepth uint64
|
netmapEpoch, netmapLookupDepth uint64
|
||||||
|
|
||||||
token *token.SessionToken
|
token *sessionsdk.Token
|
||||||
|
|
||||||
bearer *token.BearerToken
|
bearer *token.BearerToken
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ func (p *CommonPrm) LocalOnly() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *CommonPrm) WithSessionToken(token *token.SessionToken) *CommonPrm {
|
func (p *CommonPrm) WithSessionToken(token *sessionsdk.Token) *CommonPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.token = token
|
p.token = token
|
||||||
}
|
}
|
||||||
|
@ -123,7 +124,7 @@ func WithKey(key *ecdsa.PrivateKey) DynamicCallOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *CommonPrm) SessionToken() *token.SessionToken {
|
func (p *CommonPrm) SessionToken() *sessionsdk.Token {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
return p.token
|
return p.token
|
||||||
}
|
}
|
||||||
|
@ -180,7 +181,7 @@ func CommonPrmFromV2(req interface {
|
||||||
prm.callOpts = append(prm.callOpts, client.WithTTL(meta.GetTTL()-1))
|
prm.callOpts = append(prm.callOpts, client.WithTTL(meta.GetTTL()-1))
|
||||||
|
|
||||||
if tok := meta.GetSessionToken(); tok != nil {
|
if tok := meta.GetSessionToken(); tok != nil {
|
||||||
prm.token = token.NewSessionTokenFromV2(tok)
|
prm.token = sessionsdk.NewTokenFromV2(tok)
|
||||||
prm.callOpts = append(prm.callOpts, client.WithSession(prm.token))
|
prm.callOpts = append(prm.callOpts, client.WithSession(prm.token))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package storagegroup
|
||||||
import (
|
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/client"
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
@ -15,7 +15,7 @@ import (
|
||||||
// with information about members collected via HeadReceiver.
|
// with information about members collected via HeadReceiver.
|
||||||
//
|
//
|
||||||
// Resulting storage group consists of physically stored objects only.
|
// Resulting storage group consists of physically stored objects only.
|
||||||
func CollectMembers(r objutil.HeadReceiver, cid *container.ID, members []*objectSDK.ID) (*storagegroup.StorageGroup, error) {
|
func CollectMembers(r objutil.HeadReceiver, cid *cid.ID, members []*objectSDK.ID) (*storagegroup.StorageGroup, error) {
|
||||||
var (
|
var (
|
||||||
sumPhySize uint64
|
sumPhySize uint64
|
||||||
phyMembers []*objectSDK.ID
|
phyMembers []*objectSDK.ID
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/token"
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ type FormatterParams struct {
|
||||||
|
|
||||||
NextTarget ObjectTarget
|
NextTarget ObjectTarget
|
||||||
|
|
||||||
SessionToken *token.SessionToken
|
SessionToken *session.Token
|
||||||
|
|
||||||
NetworkState netmap.State
|
NetworkState netmap.State
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue