[#570] *: Remove usage of deprecated elements from API Go library

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 14:03:17 +03:00 committed by Leonard Lyubich
parent 70a7354e9d
commit 3dd10b6795
63 changed files with 285 additions and 270 deletions

View file

@ -19,6 +19,7 @@ import (
"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/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/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
@ -79,7 +80,7 @@ var listContainersCmd = &cobra.Command{
Long: "List all created containers",
RunE: func(cmd *cobra.Command, args []string) error {
var (
response []*container.ID
response []*cid.ID
oid *owner.ID
err error
@ -413,7 +414,7 @@ var getExtendedACLCmd = &cobra.Command{
}
eaclTable := res.EACL()
sig := res.Signature()
sig := eaclTable.Signature()
if containerPathTo == "" {
fmt.Println("eACL: ")
@ -613,7 +614,7 @@ func containerSessionToken() (*session.Token, error) {
return tok, nil
}
func prettyPrintContainerList(list []*container.ID) {
func prettyPrintContainerList(list []*cid.ID) {
for i := range list {
fmt.Println(list[i])
}
@ -713,14 +714,14 @@ func parseNonce(nonce string) (uuid.UUID, error) {
return uuid.Parse(nonce)
}
func parseContainerID(cid string) (*container.ID, error) {
if cid == "" {
func parseContainerID(idStr string) (*cid.ID, error) {
if idStr == "" {
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 {
return nil, errors.New("can't decode container ID value")
}

View file

@ -15,9 +15,10 @@ import (
"time"
"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/owner"
"github.com/nspcc-dev/neofs-api-go/pkg/session"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/spf13/cobra"
@ -193,7 +194,7 @@ func init() {
// 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()
if err != nil {
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
}
func getCID(cmd *cobra.Command) (*container.ID, error) {
cid := container.NewID()
err := cid.Parse(cmd.Flag("cid").Value.String())
func getCID(cmd *cobra.Command) (*cid.ID, error) {
id := cid.New()
err := id.Parse(cmd.Flag("cid").Value.String())
return cid, err
return id, err
}
func getOID(cmd *cobra.Command) (*object.ID, error) {

View file

@ -7,6 +7,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/client"
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"
"github.com/nspcc-dev/neofs-api-go/pkg/token"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -93,7 +94,7 @@ func init() {
type sgHeadReceiver struct {
ctx context.Context
tok *token.SessionToken
tok *session.Token
c client.Client

View file

@ -7,6 +7,7 @@ import (
lru "github.com/hashicorp/golang-lru"
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
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"
"github.com/nspcc-dev/neofs-node/pkg/core/container"
"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) {
cid := containerSDK.NewID()
id := cid.New()
err := cid.Parse(key.(string))
err := id.Parse(key.(string))
if err != nil {
return nil, err
}
return v.Get(cid)
return v.Get(id)
})
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())
if err != nil {
return nil, err
@ -165,20 +166,20 @@ func newCachedEACLStorage(v eacl.Storage) eacl.Storage {
)
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 {
return nil, err
}
return v.GetEACL(cid)
return v.GetEACL(id)
})
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())
if err != nil {
return nil, err

View file

@ -10,6 +10,7 @@ import (
apiClient "github.com/nspcc-dev/neofs-api-go/pkg/client"
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"
containerV2 "github.com/nspcc-dev/neofs-api-go/v2/container"
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
@ -279,7 +280,7 @@ type loadPlacementBuilder struct {
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)
if err != nil {
return nil, err
@ -299,7 +300,7 @@ func (l *loadPlacementBuilder) BuildPlacement(epoch uint64, cid *containerSDK.ID
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)
if err != nil {
return nil, nil, err
@ -433,7 +434,7 @@ func (*containerOnlyKeyRemoteServerInfo) Address() string {
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)
if err != nil {
return false, err

View file

@ -7,7 +7,7 @@ import (
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/container"
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
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/util/signature"
@ -372,7 +372,7 @@ func (s *signedEACLTable) SignedDataSize() int {
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)
if err != nil {
return nil, err

View file

@ -4,6 +4,7 @@ import (
"errors"
"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
@ -17,7 +18,7 @@ type Source interface {
//
// Implementations must not retain the container pointer and modify
// 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.

View file

@ -8,11 +8,11 @@ import (
"strconv"
"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/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/token"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-node/pkg/util/test"
@ -28,8 +28,8 @@ func testSHA(t *testing.T) [sha256.Size]byte {
return cs
}
func testContainerID(t *testing.T) *container.ID {
id := container.NewID()
func testContainerID(t *testing.T) *cid.ID {
id := cid.New()
id.SetSHA256(testSHA(t))
return id
@ -101,7 +101,7 @@ func TestFormatValidator_Validate(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))
obj := NewRaw()

View file

@ -4,7 +4,7 @@ import (
"context"
"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/object"
"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
ln := len(shuffled)

View file

@ -6,13 +6,13 @@ import (
"sort"
"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"
)
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)
if err != nil {
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
}
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 {
return nil
}

View file

@ -5,7 +5,7 @@ import (
"crypto/sha256"
"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/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
result := make([]*container.ID, 0, n)
result := make([]*cid.ID, 0, n)
for i := 0; i < n; i++ {
_, _ = rand.Read(buf[:])
cid := container.NewID()
cid.SetSHA256(buf)
id := cid.New()
id.SetSHA256(buf)
result = append(result, cid)
result = append(result, id)
}
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))
for _, id := range ids {

View file

@ -6,7 +6,7 @@ import (
"math/big"
"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/owner"
crypto "github.com/nspcc-dev/neofs-crypto"
@ -29,7 +29,7 @@ type singleResultCtx struct {
log *logger.Logger
cid *container.ID
cid *cid.ID
txTable *common.TransferTable
@ -295,7 +295,7 @@ func (c *Calculator) fillTransferTable(ctx *singleResultCtx) bool {
return false
}
func (c *singleResultCtx) containerID() *container.ID {
func (c *singleResultCtx) containerID() *cid.ID {
if c.cid == nil {
c.cid = c.auditResult.ContainerID()
}

View file

@ -3,7 +3,7 @@ package common
import (
"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"
)
@ -28,14 +28,14 @@ type ContainerInfo interface {
// storage of the NeoFS containers.
type ContainerStorage interface {
// Must return information about the container by ID.
ContainerInfo(*container.ID) (ContainerInfo, error)
ContainerInfo(*cid.ID) (ContainerInfo, error)
}
// PlacementCalculator is a component interface
// that builds placement vectors.
type PlacementCalculator interface {
// 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.

View file

@ -8,6 +8,7 @@ import (
auditAPI "github.com/nspcc-dev/neofs-api-go/pkg/audit"
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"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
@ -108,7 +109,7 @@ func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditAPI.Result,
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)
if err != nil {
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
}
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 (
nm *netmapAPI.Netmap
err error
@ -149,7 +150,7 @@ func (s settlementDeps) buildContainer(e uint64, cid *containerAPI.ID) (netmapAP
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)
if err != nil {
return nil, err

View file

@ -7,7 +7,7 @@ import (
"os"
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
@ -21,15 +21,15 @@ func testSHA256() (h [sha256.Size]byte) {
}
func testAddress() *objectSDK.Address {
cid := container.NewID()
cid.SetSHA256(testSHA256())
id := cid.New()
id.SetSHA256(testSHA256())
oid := objectSDK.NewID()
oid.SetSHA256(testSHA256())
addr := objectSDK.NewAddress()
addr.SetObjectID(oid)
addr.SetContainerID(cid)
addr.SetContainerID(id)
return addr
}

View file

@ -7,7 +7,7 @@ import (
"os"
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/util/logger/test"
@ -21,15 +21,15 @@ func testSHA256() (h [sha256.Size]byte) {
}
func testAddress() *objectSDK.Address {
cid := container.NewID()
cid.SetSHA256(testSHA256())
id := cid.New()
id.SetSHA256(testSHA256())
oid := objectSDK.NewID()
oid.SetSHA256(testSHA256())
addr := objectSDK.NewAddress()
addr.SetObjectID(oid)
addr.SetContainerID(cid)
addr.SetContainerID(id)
return addr
}

View file

@ -8,7 +8,7 @@ import (
"path"
"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"
)
@ -54,14 +54,14 @@ func addressFromString(s string) (*objectSDK.Address, error) {
return nil, err
}
cid := container.NewID()
if err := cid.Parse(ss[1]); err != nil {
id := cid.New()
if err := id.Parse(ss[1]); err != nil {
return nil, err
}
addr := objectSDK.NewAddress()
addr.SetObjectID(oid)
addr.SetContainerID(cid)
addr.SetContainerID(id)
return addr, nil
}

View file

@ -8,16 +8,16 @@ import (
"path"
"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"
"github.com/stretchr/testify/require"
)
func testCID() *container.ID {
func testCID() *cid.ID {
cs := [sha256.Size]byte{}
_, _ = rand.Read(cs[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(cs)
return id

View file

@ -1,13 +1,13 @@
package engine
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"
"go.uber.org/zap"
)
type ContainerSizePrm struct {
cid *container.ID
cid *cid.ID
}
type ContainerSizeRes struct {
@ -17,10 +17,10 @@ type ContainerSizeRes struct {
type ListContainersPrm 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 {
p.cid = cid
}
@ -32,7 +32,7 @@ func (r *ContainerSizeRes) Size() uint64 {
return r.size
}
func (r *ListContainersRes) Containers() []*container.ID {
func (r *ListContainersRes) Containers() []*cid.ID {
return r.containers
}
@ -48,11 +48,11 @@ func (e *StorageEngine) ContainerSize(prm *ContainerSizePrm) *ContainerSizeRes {
}
// 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()
}
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) {
size, err := shard.ContainerSize(s, id)
if err != nil {
@ -84,12 +84,12 @@ func (e *StorageEngine) ListContainers(_ *ListContainersPrm) *ListContainersRes
}
// 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()
}
func (e *StorageEngine) listContainers() []*container.ID {
uniqueIDs := make(map[string]*container.ID)
func (e *StorageEngine) listContainers() []*cid.ID {
uniqueIDs := make(map[string]*cid.ID)
e.iterateOverUnsortedShards(func(s *shard.Shard) (stop bool) {
cnrs, err := shard.ListContainers(s)
@ -111,7 +111,7 @@ func (e *StorageEngine) listContainers() []*container.ID {
return false
})
result := make([]*container.ID, 0, len(uniqueIDs))
result := make([]*cid.ID, 0, len(uniqueIDs))
for _, v := range uniqueIDs {
result = append(result, v)
}

View file

@ -8,7 +8,7 @@ import (
"testing"
"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"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -61,11 +61,11 @@ func testNewShard(t *testing.T, id int) *shard.Shard {
return s
}
func testCID() *container.ID {
func testCID() *cid.ID {
cs := [sha256.Size]byte{}
_, _ = rand.Read(cs[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(cs)
return id
@ -81,7 +81,7 @@ func testOID() *objectSDK.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.SetMajor(2)
version.SetMinor(1)

View file

@ -3,7 +3,7 @@ package engine
import (
"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"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
@ -12,7 +12,7 @@ import (
// SelectPrm groups the parameters of Select operation.
type SelectPrm struct {
cid *container.ID
cid *cid.ID
filters object.SearchFilters
}
@ -22,7 +22,7 @@ type SelectRes struct {
}
// 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 {
p.cid = cid
}
@ -138,7 +138,7 @@ func (e *StorageEngine) List(limit uint64) (*SelectRes, error) {
}
// 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).
WithContainerID(cid).
WithFilters(fs),

View file

@ -4,11 +4,11 @@ import (
"encoding/binary"
"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"
)
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 {
list, err = db.containers(tx)
@ -18,8 +18,8 @@ func (db *DB) Containers() (list []*container.ID, err error) {
return list, err
}
func (db *DB) containers(tx *bbolt.Tx) ([]*container.ID, error) {
result := make([]*container.ID, 0)
func (db *DB) containers(tx *bbolt.Tx) ([]*cid.ID, error) {
result := make([]*cid.ID, 0)
err := tx.ForEach(func(name []byte, _ *bbolt.Bucket) error {
id, err := parseContainerID(name)
@ -37,7 +37,7 @@ func (db *DB) containers(tx *bbolt.Tx) ([]*container.ID, error) {
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 {
size, err = db.containerSize(tx, id)
@ -47,7 +47,7 @@ func (db *DB) ContainerSize(id *container.ID) (size uint64, err error) {
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)
if err != nil {
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
}
func parseContainerID(name []byte) (*container.ID, error) {
func parseContainerID(name []byte) (*cid.ID, error) {
strName := string(name)
if strings.Contains(strName, invalidBase58String) {
return nil, nil
}
id := container.NewID()
id := cid.New()
return id, id.Parse(strName)
}
@ -78,7 +78,7 @@ func parseContainerSize(v []byte) uint64 {
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)
if err != nil {
return err

View file

@ -4,7 +4,7 @@ import (
"math/rand"
"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"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/stretchr/testify/require"
@ -80,8 +80,8 @@ func TestDB_ContainerSize(t *testing.T) {
N = 5
)
cids := make(map[*container.ID]int, C)
objs := make(map[*container.ID][]*object.RawObject, C*N)
cids := make(map[*cid.ID]int, C)
objs := make(map[*cid.ID][]*object.RawObject, C*N)
for i := 0; i < C; i++ {
cid := testCID()

View file

@ -7,7 +7,7 @@ import (
"testing"
"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"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"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)
}
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)
require.NoError(t, err)
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{}
_, _ = rand.Read(cs[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(cs)
return id
@ -71,7 +71,7 @@ func generateRawObject(t *testing.T) *object.RawObject {
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.SetMajor(2)
version.SetMinor(1)

View file

@ -4,7 +4,7 @@ import (
"errors"
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"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
// 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)
if len(rawSplitInfo) == 0 {
return nil, ErrLackSplitInfo

View file

@ -3,7 +3,7 @@ package meta
import (
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"go.etcd.io/bbolt"
@ -120,7 +120,7 @@ func getFromBucket(tx *bbolt.Tx, name, key []byte) []byte {
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 {
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
}
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)
if err == nil {
return objectSDK.NewSplitInfoError(splitInfo)

View file

@ -5,7 +5,7 @@ import (
"fmt"
"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"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"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)
}
cid := container.NewID()
cnrID := cid.New()
err = cid.Parse(string(cidBytes))
err = cnrID.Parse(string(cidBytes))
if err != nil {
return fmt.Errorf("could not parse container ID of expired bucket: %w", err)
}
addr := object.NewAddress()
addr.SetContainerID(cid)
addr.SetContainerID(cnrID)
addr.SetObjectID(id)
return h(&ExpiredObject{
typ: objectType(tx, cid, idKey),
typ: objectType(tx, cnrID, idKey),
addr: addr,
})
})
@ -100,7 +100,7 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
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 {
default:
return object.TypeRegular

View file

@ -6,7 +6,7 @@ import (
"fmt"
"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"
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
"go.etcd.io/bbolt"
@ -19,7 +19,7 @@ type (
// objects, and slow filters, that applied after fast filters created
// smaller set of objects to check.
filterGroup struct {
cid *container.ID
cid *cid.ID
fastFilters object.SearchFilters
slowFilters object.SearchFilters
}
@ -27,7 +27,7 @@ type (
// SelectPrm groups the parameters of Select operation.
type SelectPrm struct {
cid *container.ID
cid *cid.ID
filters object.SearchFilters
}
@ -37,7 +37,7 @@ type SelectRes struct {
}
// 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 {
p.cid = cid
}
@ -62,7 +62,7 @@ func (r *SelectRes) AddressList() []*object.Address {
var ErrMissingContainerID = errors.New("missing container id field")
// 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))
if err != nil {
return nil, err
@ -84,7 +84,7 @@ func (db *DB) Select(prm *SelectPrm) (res *SelectRes, err error) {
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 {
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.
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() + "/"
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.
func (db *DB) selectFastFilter(
tx *bbolt.Tx,
cid *container.ID, // container we search on
cid *cid.ID, // container we search on
f object.SearchFilter, // fast filter
to map[string]int, // resulting cache
fNum int, // index of filter
@ -222,13 +222,13 @@ func (db *DB) selectFastFilter(
}
// 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.TypeTombstone.String(): {tombstoneBucketName},
v2object.TypeStorageGroup.String(): {storageGroupBucketName},
}
func allBucketNames(cid *container.ID) (names [][]byte) {
func allBucketNames(cid *cid.ID) (names [][]byte) {
for _, fns := range mBucketNaming {
for _, fn := range fns {
names = append(names, fn(cid))
@ -238,7 +238,7 @@ func allBucketNames(cid *container.ID) (names [][]byte) {
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) {
fns, ok := mBucketNaming[key]
if ok {
@ -426,7 +426,7 @@ func (db *DB) selectFromList(
func (db *DB) selectObjectID(
tx *bbolt.Tx,
f object.SearchFilter,
cid *container.ID,
cid *cid.ID,
to map[string]int, // resulting cache
fNum int, // index of filter
) {
@ -540,7 +540,7 @@ func groupFilters(filters object.SearchFilters) (*filterGroup, error) {
for i := range filters {
switch filters[i].Header() {
case v2object.FilterHeaderContainerID: // support deprecated field
res.cid = container.NewID()
res.cid = cid.New()
err := res.cid.Parse(filters[i].Value())
if err != nil {

View file

@ -4,7 +4,7 @@ import (
"bytes"
"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"
)
@ -39,27 +39,27 @@ var (
)
// primaryBucketName returns <CID>.
func primaryBucketName(cid *container.ID) []byte {
func primaryBucketName(cid *cid.ID) []byte {
return []byte(cid.String())
}
// tombstoneBucketName returns <CID>_TS.
func tombstoneBucketName(cid *container.ID) []byte {
func tombstoneBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + tombstonePostfix)
}
// storageGroupBucketName returns <CID>_SG.
func storageGroupBucketName(cid *container.ID) []byte {
func storageGroupBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + storageGroupPostfix)
}
// 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
}
// 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.WriteString(cid.String())
sb.WriteString(userAttributePostfix)
@ -79,27 +79,27 @@ func cidFromAttributeBucket(val []byte, attributeKey string) []byte {
}
// payloadHashBucketName returns <CID>_payloadhash.
func payloadHashBucketName(cid *container.ID) []byte {
func payloadHashBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + payloadHashPostfix)
}
// rootBucketName returns <CID>_root.
func rootBucketName(cid *container.ID) []byte {
func rootBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + rootPostfix)
}
// ownerBucketName returns <CID>_ownerid.
func ownerBucketName(cid *container.ID) []byte {
func ownerBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + ownerPostfix)
}
// parentBucketName returns <CID>_parent.
func parentBucketName(cid *container.ID) []byte {
func parentBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + parentPostfix)
}
// splitBucketName returns <CID>_splitid.
func splitBucketName(cid *container.ID) []byte {
func splitBucketName(cid *cid.ID) []byte {
return []byte(cid.String() + splitPostfix)
}

View file

@ -3,18 +3,18 @@ package shard
import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
)
type ContainerSizePrm struct {
cid *container.ID
cid *cid.ID
}
type ContainerSizeRes struct {
size uint64
}
func (p *ContainerSizePrm) WithContainerID(cid *container.ID) *ContainerSizePrm {
func (p *ContainerSizePrm) WithContainerID(cid *cid.ID) *ContainerSizePrm {
if p != nil {
p.cid = cid
}
@ -37,7 +37,7 @@ func (s *Shard) ContainerSize(prm *ContainerSizePrm) (*ContainerSizeRes, error)
}, 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})
if err != nil {
return 0, err

View file

@ -3,7 +3,7 @@ package shard
import (
"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"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"go.uber.org/zap"
@ -12,10 +12,10 @@ import (
type ListContainersPrm 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
}
@ -55,7 +55,7 @@ func (s *Shard) ListContainers(_ *ListContainersPrm) (*ListContainersRes, error)
}, nil
}
func ListContainers(s *Shard) ([]*container.ID, error) {
func ListContainers(s *Shard) ([]*cid.ID, error) {
res, err := s.ListContainers(&ListContainersPrm{})
if err != nil {
return nil, err

View file

@ -3,14 +3,14 @@ package shard
import (
"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"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
)
// SelectPrm groups the parameters of Select operation.
type SelectPrm struct {
cid *container.ID
cid *cid.ID
filters objectSDK.SearchFilters
}
@ -20,7 +20,7 @@ type SelectRes struct {
}
// 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 {
p.cid = cid
}

View file

@ -8,7 +8,7 @@ import (
"testing"
"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"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -64,7 +64,7 @@ func generateRawObject(t *testing.T) *object.RawObject {
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.SetMajor(2)
version.SetMinor(1)
@ -110,11 +110,11 @@ func addPayload(obj *object.RawObject, size int) {
obj.SetPayloadSize(uint64(size))
}
func generateCID() *container.ID {
func generateCID() *cid.ID {
cs := [sha256.Size]byte{}
_, _ = rand.Read(cs[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(cs)
return id

View file

@ -5,7 +5,7 @@ import (
"fmt"
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"
)
@ -59,7 +59,7 @@ func (w *ClientWrapper) ListAuditResultIDByEpoch(epoch uint64) ([]ResultID, erro
// ListAuditResultIDByCID returns a list of audit result IDs inside audit
// 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.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
// 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.SetEpoch(int64(epoch))
args.SetNodeKey(key)

View file

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util"
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"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
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)
require.NoError(t, err)
cid := container.NewID()
cid.SetSHA256([sha256.Size]byte{1, 2, 3})
id := cid.New()
id.SetSHA256([sha256.Size]byte{1, 2, 3})
auditRes := auditAPI.NewResult()
auditRes.SetAuditEpoch(epoch)
auditRes.SetPublicKey(pubKey)
auditRes.SetContainerID(cid)
auditRes.SetContainerID(id)
require.NoError(t, auditClientWrapper.PutAuditResult(auditRes))
time.Sleep(5 * time.Second)
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, cid)
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, id)
require.NoError(t, err)
require.Len(t, list, 1)

View file

@ -81,7 +81,7 @@ func (w *Wrapper) Put(cnr, key, sig, token []byte) error {
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)
}
@ -94,7 +94,7 @@ func AsContainerSource(w *Wrapper) core.Source {
// Get marshals container ID, and passes it to Wrapper's Get method.
//
// 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())
}
@ -194,7 +194,7 @@ func (w *Wrapper) Delete(cid, signature, token []byte) error {
//
// Returns the identifiers of all NeoFS containers if pointer
// 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{}
if ownerID == nil {
@ -212,15 +212,15 @@ func (w *Wrapper) List(ownerID *owner.ID) ([]*container.ID, error) {
}
rawIDs := rpcAnswer.CIDList()
result := make([]*container.ID, 0, len(rawIDs))
result := make([]*cid.ID, 0, len(rawIDs))
for i := range rawIDs {
v2 := new(v2refs.ContainerID)
v2.SetValue(rawIDs[i])
cid := container.NewIDFromV2(v2)
id := cid.NewFromV2(v2)
result = append(result, cid)
result = append(result, id)
}
return result, nil
@ -280,7 +280,7 @@ type Estimation struct {
// Estimation is a structure of grouped container load estimation inside Container contract.
type Estimations struct {
ContainerID *container.ID
ContainerID *cid.ID
Values []Estimation
}
@ -302,7 +302,7 @@ func (w *Wrapper) GetUsedSpaceEstimations(id EstimationID) (*Estimations, error)
v2.SetValue(es.ContainerID)
res := &Estimations{
ContainerID: container.NewIDFromV2(v2),
ContainerID: cid.NewFromV2(v2),
Values: make([]Estimation, 0, len(es.Estimations)),
}

View file

@ -4,7 +4,7 @@ import (
"sync"
"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/object"
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
@ -150,7 +150,7 @@ func (c *Context) WithPoRWorkerPool(pool util.WorkerPool) *Context {
return c
}
func (c *Context) containerID() *container.ID {
func (c *Context) containerID() *cid.ID {
return c.task.ContainerID()
}

View file

@ -4,7 +4,7 @@ import (
"sync"
"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"
)
@ -21,7 +21,7 @@ type Reporter interface {
}
// NewReport creates and returns blank Report instance.
func NewReport(cid *container.ID) *Report {
func NewReport(cid *cid.ID) *Report {
rep := &Report{
res: audit.NewResult(),
}

View file

@ -4,6 +4,7 @@ import (
"context"
"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/object"
)
@ -14,7 +15,7 @@ type Task struct {
auditContext context.Context
cid *container.ID
cid *cid.ID
cnr *container.Container
@ -54,7 +55,7 @@ func (t *Task) AuditContext() context.Context {
}
// 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 {
t.cid = cid
}
@ -63,7 +64,7 @@ func (t *Task) WithContainerID(cid *container.ID) *Task {
}
// ContainerID returns identifier of the container under audit.
func (t *Task) ContainerID() *container.ID {
func (t *Task) ContainerID() *cid.ID {
return t.cid
}

View file

@ -8,6 +8,7 @@ import (
"testing"
"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"
"github.com/stretchr/testify/require"
)
@ -73,12 +74,12 @@ func (s *testAnnouncementStorage) Close() error {
return nil
}
func randCID() *container.ID {
func randCID() *cid.ID {
h := [sha256.Size]byte{}
rand.Read(h[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(h)
return id

View file

@ -1,7 +1,7 @@
package placementrouter
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"
)
@ -10,5 +10,5 @@ type PlacementBuilder interface {
// BuildPlacement must compose and sort (according to a specific algorithm)
// storage nodes from the container with identifier cid using network map
// of particular epoch.
BuildPlacement(epoch uint64, cid *container.ID) ([]netmap.Nodes, error)
BuildPlacement(epoch uint64, cid *cid.ID) ([]netmap.Nodes, error)
}

View file

@ -6,15 +6,16 @@ import (
"testing"
"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"
)
func randCID() *container.ID {
func randCID() *cid.ID {
h := [sha256.Size]byte{}
rand.Read(h[:])
id := container.NewID()
id := cid.New()
id.SetSHA256(h)
return id

View file

@ -7,6 +7,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
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/session"
"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) {
cid := containerSDK.NewIDFromV2(body.GetContainerID())
id := cid.NewFromV2(body.GetContainerID())
sig := body.GetSignature().GetSign()
tok := session.NewTokenFromV2(ctx.SessionToken)
var rmWitness containercore.RemovalWitness
rmWitness.SetContainerID(cid)
rmWitness.SetContainerID(id)
rmWitness.SetSignature(sig)
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) {
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 {
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) {
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 {
return nil, err
}

View file

@ -7,7 +7,7 @@ import (
"fmt"
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"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/util/signature"
@ -69,7 +69,7 @@ type (
operation acl.Operation // put, get, head, etc.
cnrOwner *owner.ID // container owner
cid *container.ID
cid *cid.ID
oid *objectSDK.ID
@ -225,9 +225,9 @@ func (b Service) Head(
}
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 {
return err
}
@ -239,7 +239,7 @@ func (b Service) Search(request *object.SearchRequest, stream objectSvc.SearchSt
src: request,
}
reqInfo, err := b.findRequestInfo(req, cid, acl.OperationSearch)
reqInfo, err := b.findRequestInfo(req, id, acl.OperationSearch)
if err != nil {
return err
}
@ -440,7 +440,7 @@ func (g *searchStreamBasicChecker) Send(resp *object.SearchResponse) error {
func (b Service) findRequestInfo(
req metaWithToken,
cid *container.ID,
cid *cid.ID,
op acl.Operation) (info requestInfo, err error) {
cnr, err := b.containers.Get(cid) // fetch actual container
if err != nil || cnr.OwnerID() == nil {
@ -480,27 +480,27 @@ func (b Service) findRequestInfo(
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) {
case *object.GetRequest:
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
case *object.PutRequest:
objPart := v.GetBody().GetObjectPart()
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")
case *object.HeadRequest:
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
case *object.SearchRequest:
return container.NewIDFromV2(v.GetBody().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetContainerID()), nil
case *object.DeleteRequest:
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
case *object.GetRangeRequest:
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
case *object.GetRangeHashRequest:
return container.NewIDFromV2(v.GetBody().GetAddress().GetContainerID()), nil
return cid.NewFromV2(v.GetBody().GetAddress().GetContainerID()), nil
default:
return nil, errors.New("unknown request type")
}

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
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"
"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/util/signature"
@ -49,7 +50,7 @@ func NewSenderClassifier(l *zap.Logger, ir InnerRingFetcher, nm core.Source) Sen
func (c SenderClassifier) Classify(
req metaWithToken,
cid *container.ID,
cid *cid.ID,
cnr *container.Container) (role acl.Role, isIR bool, key []byte, err error) {
if cid == nil {
return 0, false, nil, fmt.Errorf("%w: container id is not set", ErrMalformedRequest)

View file

@ -2,7 +2,7 @@ package eacl
import (
"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"
)
@ -16,7 +16,7 @@ type Storage interface {
//
// Must return pkg/core/container.ErrEACLNotFound if requested
// 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.
@ -38,7 +38,7 @@ type TypedHeaderSource interface {
// ValidationUnit represents unit of check for Validator.
type ValidationUnit struct {
cid *container.ID
cid *cid.ID
role eacl.Role
@ -51,7 +51,7 @@ type ValidationUnit struct {
bearer *bearer.BearerToken
}
func (u *ValidationUnit) WithContainerID(v *container.ID) *ValidationUnit {
func (u *ValidationUnit) WithContainerID(v *cid.ID) *ValidationUnit {
if u != nil {
u.cid = v
}

View file

@ -6,7 +6,7 @@ import (
"testing"
"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"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-api-go/v2/session"
@ -28,12 +28,12 @@ type testLocalStorage struct {
type testEACLStorage struct {
t *testing.T
expCID *container.ID
expCID *cid.ID
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))
return s.table, nil
@ -57,13 +57,13 @@ func testID(t *testing.T) *objectSDK.ID {
return id
}
func testCID(t *testing.T) *container.ID {
func testCID(t *testing.T) *cid.ID {
cs := [sha256.Size]byte{}
_, err := rand.Read(cs[:])
require.NoError(t, err)
id := container.NewID()
id := cid.New()
id.SetSHA256(cs)
return id

View file

@ -5,7 +5,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
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"
"github.com/nspcc-dev/neofs-api-go/v2/acl"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
@ -110,7 +110,7 @@ func (h *headerSource) objectHeaders() ([]eacl.Header, bool) {
if addr == nil {
addr = objectSDK.NewAddress()
addr.SetContainerID(container.NewIDFromV2(v.GetHeader().GetContainerID()))
addr.SetContainerID(cid.NewFromV2(v.GetHeader().GetContainerID()))
addr.SetObjectID(objectSDK.NewIDFromV2(v.GetObjectID()))
}
@ -120,7 +120,7 @@ func (h *headerSource) objectHeaders() ([]eacl.Header, bool) {
}
case *objectV2.SearchRequest:
return []eacl.Header{cidHeader(
container.NewIDFromV2(
cid.NewFromV2(
req.GetBody().GetContainerID()),
)}, true
}
@ -176,7 +176,7 @@ func (h *headerSource) localObjectHeaders(addrV2 *refs.Address) ([]eacl.Header,
return addressHeaders(addr), false
}
func cidHeader(cid *container.ID) eacl.Header {
func cidHeader(cid *cid.ID) eacl.Header {
return &sysObjHdr{
k: acl.FilterObjectContainerID,
v: cidValue(cid),

View file

@ -3,7 +3,7 @@ package v2
import (
"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"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/v2/acl"
@ -27,7 +27,7 @@ func idValue(id *objectSDK.ID) string {
return id.String()
}
func cidValue(id *container.ID) string {
func cidValue(id *cid.ID) string {
return id.String()
}

View file

@ -4,7 +4,7 @@ import (
"context"
"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"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -63,7 +63,7 @@ func (exec *execCtx) address() *objectSDK.Address {
return exec.prm.Address()
}
func (exec *execCtx) containerID() *container.ID {
func (exec *execCtx) containerID() *cid.ID {
return exec.prm.Address().ContainerID()
}

View file

@ -2,7 +2,7 @@ package deletesvc
import (
"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"
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
"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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(session.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
return nil, err
}

View file

@ -6,7 +6,7 @@ import (
"errors"
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/network"
@ -134,7 +134,7 @@ func (exec *execCtx) splitInfo() *objectSDK.SplitInfo {
return exec.infoSplit
}
func (exec *execCtx) containerID() *container.ID {
func (exec *execCtx) containerID() *cid.ID {
return exec.address().ContainerID()
}

View file

@ -10,6 +10,7 @@ import (
"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/netmap"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -191,10 +192,10 @@ func generateAddress() *objectSDK.Address {
addr := objectSDK.NewAddress()
addr.SetObjectID(generateID())
cid := container.NewID()
cid.SetSHA256(testSHA256())
id := cid.New()
id.SetSHA256(testSHA256())
addr.SetContainerID(cid)
addr.SetContainerID(id)
return addr
}
@ -432,7 +433,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) {
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()
var prevID *objectSDK.ID

View file

@ -11,7 +11,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/client"
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"
signature2 "github.com/nspcc-dev/neofs-api-go/util/signature"
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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
return nil, err
}

View file

@ -3,7 +3,7 @@ package searchsvc
import (
"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"
"github.com/nspcc-dev/neofs-node/pkg/network"
"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()
}
func (exec *execCtx) containerID() *container.ID {
func (exec *execCtx) containerID() *cid.ID {
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)
switch {

View file

@ -10,6 +10,7 @@ import (
"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/netmap"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"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(
placement.ForContainer(g.c),
placement.UseBuilder(g.b[epoch]),
@ -114,7 +115,7 @@ func (c *testStorage) searchObjects(exec *execCtx) ([]*objectSDK.ID, error) {
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{
ids: ids,
err: err,
@ -126,11 +127,11 @@ func testSHA256() (cs [sha256.Size]byte) {
return cs
}
func generateCID() *container.ID {
cid := container.NewID()
cid.SetSHA256(testSHA256())
func generateCID() *cid.ID {
id := cid.New()
id.SetSHA256(testSHA256())
return cid
return id
}
func generateIDs(num int) []*objectSDK.ID {
@ -155,7 +156,7 @@ func TestGetLocalOnly(t *testing.T) {
return svc
}
newPrm := func(cid *container.ID, w IDListWriter) Prm {
newPrm := func(cid *cid.ID, w IDListWriter) Prm {
p := Prm{}
p.WithContainerID(cid)
p.SetWriter(w)
@ -247,7 +248,7 @@ func TestGetRemoteSmall(t *testing.T) {
pp.SetReplicas(rs...)
cnr := container.New(container.WithPolicy(pp))
cid := container.CalculateID(cnr)
id := container.CalculateID(cnr)
newSvc := func(b *testPlacementBuilder, c *testClientCache) *Service {
svc := &Service{cfg: new(cfg)}
@ -268,9 +269,9 @@ func TestGetRemoteSmall(t *testing.T) {
return svc
}
newPrm := func(cid *container.ID, w IDListWriter) Prm {
newPrm := func(id *cid.ID, w IDListWriter) Prm {
p := Prm{}
p.WithContainerID(cid)
p.WithContainerID(id)
p.SetWriter(w)
p.common = new(util.CommonPrm).WithLocalOnly(false)
@ -279,7 +280,7 @@ func TestGetRemoteSmall(t *testing.T) {
t.Run("OK", func(t *testing.T) {
addr := objectSDK.NewAddress()
addr.SetContainerID(cid)
addr.SetContainerID(id)
ns, as := testNodeMatrix(t, placementDim)
@ -291,11 +292,11 @@ func TestGetRemoteSmall(t *testing.T) {
c1 := newTestStorage()
ids1 := generateIDs(10)
c1.addResult(cid, ids1, nil)
c1.addResult(id, ids1, nil)
c2 := newTestStorage()
ids2 := generateIDs(10)
c2.addResult(cid, ids2, nil)
c2.addResult(id, ids2, nil)
svc := newSvc(builder, &testClientCache{
clients: map[string]*testStorage{
@ -306,7 +307,7 @@ func TestGetRemoteSmall(t *testing.T) {
w := new(simpleIDWriter)
p := newPrm(cid, w)
p := newPrm(id, w)
err := svc.Search(ctx, p)
require.NoError(t, err)

View file

@ -2,7 +2,7 @@ package searchsvc
import (
"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-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
@ -42,7 +42,7 @@ type cfg struct {
}
traverserGenerator interface {
generateTraverser(*container.ID, uint64) (*placement.Traverser, error)
generateTraverser(*cid.ID, uint64) (*placement.Traverser, error)
}
currentEpochReceiver interface {

View file

@ -4,7 +4,7 @@ import (
"sync"
"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"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
@ -111,7 +111,7 @@ func idsFromAddresses(addrs []*objectSDK.Address) []*objectSDK.ID {
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.SetContainerID(cid)

View file

@ -7,9 +7,9 @@ import (
"sync"
"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"
"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"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"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) {
meta := req.GetMetaHeader()
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
key, err := s.keyStorage.GetKey(sessionsdk.NewTokenFromV2(meta.GetSessionToken()))
if err != nil {
return nil, err
}
@ -104,7 +104,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
}
body := req.GetBody()
p.WithContainerID(container.NewIDFromV2(body.GetContainerID()))
p.WithContainerID(cid.NewFromV2(body.GetContainerID()))
p.WithSearchFilters(objectSDK.NewSearchFiltersFromV2(body.GetFilters()))
return p, nil

View file

@ -3,7 +3,7 @@ package util
import (
"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"
)
@ -26,7 +26,7 @@ func NewKeyStorage(localKey *ecdsa.PrivateKey, tokenStore *storage.TokenStore) *
//
// If token is not nil, session 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 {
pToken := s.tokenStore.Get(token.OwnerID(), token.ID())
if pToken != nil {

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
"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/v2/session"
)
@ -15,7 +16,7 @@ type CommonPrm struct {
netmapEpoch, netmapLookupDepth uint64
token *token.SessionToken
token *sessionsdk.Token
bearer *token.BearerToken
@ -46,7 +47,7 @@ func (p *CommonPrm) LocalOnly() bool {
return false
}
func (p *CommonPrm) WithSessionToken(token *token.SessionToken) *CommonPrm {
func (p *CommonPrm) WithSessionToken(token *sessionsdk.Token) *CommonPrm {
if p != nil {
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 {
return p.token
}
@ -180,7 +181,7 @@ func CommonPrmFromV2(req interface {
prm.callOpts = append(prm.callOpts, client.WithTTL(meta.GetTTL()-1))
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))
}

View file

@ -3,7 +3,7 @@ package storagegroup
import (
"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/container"
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -15,7 +15,7 @@ import (
// with information about members collected via HeadReceiver.
//
// 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 (
sumPhySize uint64
phyMembers []*objectSDK.ID

View file

@ -6,7 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg"
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/object"
)
@ -25,7 +25,7 @@ type FormatterParams struct {
NextTarget ObjectTarget
SessionToken *token.SessionToken
SessionToken *session.Token
NetworkState netmap.State
}