forked from TrueCloudLab/frostfs-node
[#1400] owner: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f8ac4632f8
commit
bb25ecbd15
60 changed files with 379 additions and 327 deletions
|
@ -14,9 +14,9 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
morphsubnet "github.com/nspcc-dev/neofs-node/pkg/morph/client/subnet"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/rand"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/subnet"
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -217,7 +217,8 @@ var cmdSubnetCreate = &cobra.Command{
|
|||
}
|
||||
|
||||
// declare creator ID and encode it
|
||||
creator := *owner.NewIDFromPublicKey(&key.PrivateKey.PublicKey)
|
||||
var creator user.ID
|
||||
user.IDFromKey(&creator, key.PrivateKey.PublicKey)
|
||||
|
||||
// fill subnet info and encode it
|
||||
var info subnet.Info
|
||||
|
@ -393,7 +394,7 @@ var cmdSubnetGet = &cobra.Command{
|
|||
}
|
||||
|
||||
// print information
|
||||
var ownerID owner.ID
|
||||
var ownerID user.ID
|
||||
|
||||
info.ReadOwner(&ownerID)
|
||||
|
||||
|
@ -607,18 +608,13 @@ func manageSubnetClients(cmd *cobra.Command, rm bool) error {
|
|||
}
|
||||
|
||||
// read client ID and encode it
|
||||
var clientID owner.ID
|
||||
var clientID user.ID
|
||||
|
||||
err = clientID.Parse(viper.GetString(flagSubnetClientID))
|
||||
err = clientID.DecodeString(viper.GetString(flagSubnetClientID))
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode client ID text: %w", err)
|
||||
}
|
||||
|
||||
binClientID, err := clientID.Marshal()
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal client ID: %w", err)
|
||||
}
|
||||
|
||||
// read group ID and encode it
|
||||
var groupID internal.SubnetClientGroupID
|
||||
|
||||
|
@ -636,7 +632,7 @@ func manageSubnetClients(cmd *cobra.Command, rm bool) error {
|
|||
|
||||
prm.SetGroup(binGroupID)
|
||||
prm.SetSubnet(binID)
|
||||
prm.SetClient(binClientID)
|
||||
prm.SetClient(clientID.WalletBytes())
|
||||
|
||||
if rm {
|
||||
prm.SetRemove()
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/precision"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/accounting"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -24,18 +24,16 @@ var accountingBalanceCmd = &cobra.Command{
|
|||
Short: "Get internal balance of NeoFS account",
|
||||
Long: `Get internal balance of NeoFS account`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var oid *owner.ID
|
||||
var oid user.ID
|
||||
|
||||
pk, err := key.GetOrGenerate()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
balanceOwner, _ := cmd.Flags().GetString(ownerFlag)
|
||||
if balanceOwner == "" {
|
||||
oid = owner.NewIDFromPublicKey(&pk.PublicKey)
|
||||
user.IDFromKey(&oid, pk.PublicKey)
|
||||
} else {
|
||||
oid := owner.NewID()
|
||||
err := oid.Parse(balanceOwner)
|
||||
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", err)
|
||||
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", oid.DecodeString(balanceOwner))
|
||||
}
|
||||
|
||||
cli, err := internalclient.GetSDKClientByFlag(pk, commonflags.RPC)
|
||||
|
@ -43,7 +41,7 @@ var accountingBalanceCmd = &cobra.Command{
|
|||
|
||||
var prm internalclient.BalanceOfPrm
|
||||
prm.SetClient(cli)
|
||||
prm.SetAccount(*oid)
|
||||
prm.SetAccount(oid)
|
||||
|
||||
res, err := internalclient.BalanceOf(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -96,8 +96,9 @@ func createToken(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
ownerStr, _ := cmd.Flags().GetString(ownerFlag)
|
||||
ownerID := owner.NewID()
|
||||
if err := ownerID.Parse(ownerStr); err != nil {
|
||||
|
||||
var ownerID user.ID
|
||||
if err := ownerID.DecodeString(ownerStr); err != nil {
|
||||
return fmt.Errorf("can't parse recipient: %w", err)
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ func createToken(cmd *cobra.Command, _ []string) error {
|
|||
b.SetExpiration(exp)
|
||||
b.SetNotBefore(nvb)
|
||||
b.SetIssuedAt(iat)
|
||||
b.SetOwnerID(*ownerID)
|
||||
b.SetOwnerID(ownerID)
|
||||
|
||||
eaclPath, _ := cmd.Flags().GetString(eaclFlag)
|
||||
if eaclPath != "" {
|
||||
|
|
|
@ -23,10 +23,10 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
versionSDK "github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -114,22 +114,21 @@ var listContainersCmd = &cobra.Command{
|
|||
Short: "List all created containers",
|
||||
Long: "List all created containers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var oid *owner.ID
|
||||
var idUser user.ID
|
||||
|
||||
key, err := getKey()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
if containerOwner == "" {
|
||||
oid = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||
user.IDFromKey(&idUser, key.PublicKey)
|
||||
} else {
|
||||
oid, err = ownerFromString(containerOwner)
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
common.ExitOnErr(cmd, "", userFromString(&idUser, containerOwner))
|
||||
}
|
||||
|
||||
var prm internalclient.ListContainersPrm
|
||||
|
||||
prepareAPIClientWithKey(cmd, key, &prm)
|
||||
prm.SetAccount(*oid)
|
||||
prm.SetAccount(idUser)
|
||||
|
||||
res, err := internalclient.ListContainers(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
@ -168,10 +167,11 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
|||
key, err := getKey()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
var idOwner *owner.ID
|
||||
var idOwner *user.ID
|
||||
|
||||
if idOwner = tok.OwnerID(); idOwner == nil {
|
||||
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||
idOwner = new(user.ID)
|
||||
user.IDFromKey(idOwner, key.PublicKey)
|
||||
}
|
||||
|
||||
ver := versionSDK.Current()
|
||||
|
|
|
@ -27,8 +27,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -335,7 +335,7 @@ func prepareSessionPrmWithOwner(
|
|||
cmd *cobra.Command,
|
||||
addr *addressSDK.Address,
|
||||
key *ecdsa.PrivateKey,
|
||||
ownerID *owner.ID,
|
||||
ownerID *user.ID,
|
||||
prms ...clientKeySession,
|
||||
) {
|
||||
cli, err := internalclient.GetSDKClientByFlag(key, commonflags.RPC)
|
||||
|
@ -739,8 +739,11 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
|||
}
|
||||
}
|
||||
|
||||
func getOwnerID(key *ecdsa.PrivateKey) (*owner.ID, error) {
|
||||
return owner.NewIDFromPublicKey(&key.PublicKey), nil
|
||||
func getOwnerID(key *ecdsa.PrivateKey) (*user.ID, error) {
|
||||
var res user.ID
|
||||
user.IDFromKey(&res, key.PublicKey)
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
var searchUnaryOpVocabulary = map[string]object.SearchMatchType{
|
||||
|
|
|
@ -2,7 +2,6 @@ package cmd
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -21,8 +20,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/util/gendoc"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -187,16 +186,14 @@ func getTTL() uint32 {
|
|||
return ttl
|
||||
}
|
||||
|
||||
// ownerFromString converts string with NEO3 wallet address to neofs owner ID.
|
||||
func ownerFromString(s string) (*owner.ID, error) {
|
||||
result := owner.NewID()
|
||||
|
||||
err := result.Parse(s)
|
||||
// userFromString decodes user ID from string input.
|
||||
func userFromString(id *user.ID, s string) error {
|
||||
err := id.DecodeString(s)
|
||||
if err != nil {
|
||||
return nil, errors.New("can't decode owner ID wallet address")
|
||||
return fmt.Errorf("invalid user ID: %w", err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func printVerbose(format string, a ...interface{}) {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -69,8 +69,10 @@ func createSession(cmd *cobra.Command, _ []string) error {
|
|||
lifetime = lfArg
|
||||
}
|
||||
|
||||
ownerID := owner.NewIDFromPublicKey(&privKey.PublicKey)
|
||||
tok, err := CreateSession(c, ownerID, lifetime)
|
||||
var ownerID user.ID
|
||||
user.IDFromKey(&ownerID, privKey.PublicKey)
|
||||
|
||||
tok, err := CreateSession(c, &ownerID, lifetime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -95,7 +97,7 @@ func createSession(cmd *cobra.Command, _ []string) error {
|
|||
|
||||
// CreateSession returns newly created session token with the specified owner and lifetime.
|
||||
// `Issued-At` and `Not-Valid-Before` fields are set to current epoch.
|
||||
func CreateSession(c *client.Client, owner *owner.ID, lifetime uint64) (*session.Token, error) {
|
||||
func CreateSession(c *client.Client, owner *user.ID, lifetime uint64) (*session.Token, error) {
|
||||
var netInfoPrm internalclient.NetworkInfoPrm
|
||||
netInfoPrm.SetClient(c)
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
storagegroupAPI "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -140,7 +140,7 @@ func init() {
|
|||
type sgHeadReceiver struct {
|
||||
cmd *cobra.Command
|
||||
key *ecdsa.PrivateKey
|
||||
ownerID *owner.ID
|
||||
ownerID *user.ID
|
||||
prm internalclient.HeadObjectPrm
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
)
|
||||
|
||||
type netValueReader func(interface{}) (interface{}, error)
|
||||
|
@ -248,14 +248,14 @@ func newCachedContainerLister(c *cntClient.Client) *ttlContainerLister {
|
|||
|
||||
lruCnrListerCache := newNetworkTTLCache(containerListerCacheSize, containerListerCacheTTL, func(key interface{}) (interface{}, error) {
|
||||
var (
|
||||
id *owner.ID
|
||||
id *user.ID
|
||||
strID = key.(string)
|
||||
)
|
||||
|
||||
if strID != "" {
|
||||
id = owner.NewID()
|
||||
id = new(user.ID)
|
||||
|
||||
err := id.Parse(strID)
|
||||
err := id.DecodeString(strID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ func newCachedContainerLister(c *cntClient.Client) *ttlContainerLister {
|
|||
// List returns list of container IDs from the cache. If list is missing in the
|
||||
// cache or expired, then it returns container IDs from side chain and updates
|
||||
// the cache.
|
||||
func (s *ttlContainerLister) List(id *owner.ID) ([]*cid.ID, error) {
|
||||
func (s *ttlContainerLister) List(id *user.ID) ([]*cid.ID, error) {
|
||||
var str string
|
||||
|
||||
if id != nil {
|
||||
|
@ -286,7 +286,7 @@ func (s *ttlContainerLister) List(id *owner.ID) ([]*cid.ID, error) {
|
|||
}
|
||||
|
||||
// InvalidateContainerList removes cached list of container IDs.
|
||||
func (s *ttlContainerLister) InvalidateContainerList(id *owner.ID) {
|
||||
func (s *ttlContainerLister) InvalidateContainerList(id *user.ID) {
|
||||
(*ttlNetCache)(s).remove(id.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/state"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"go.etcd.io/bbolt"
|
||||
|
@ -77,7 +77,7 @@ type cfg struct {
|
|||
|
||||
key *keys.PrivateKey
|
||||
|
||||
ownerIDFromKey *owner.ID // owner ID calculated from key
|
||||
ownerIDFromKey user.ID // user ID calculated from key
|
||||
|
||||
apiVersion version.Version
|
||||
|
||||
|
@ -234,8 +234,6 @@ func initCfg(path string) *cfg {
|
|||
|
||||
key := nodeconfig.Key(appCfg)
|
||||
|
||||
ownerIDFromKey := owner.NewIDFromPublicKey(&key.PrivateKey.PublicKey)
|
||||
|
||||
var logPrm logger.Prm
|
||||
|
||||
err := logPrm.SetLevelString(
|
||||
|
@ -316,10 +314,10 @@ func initCfg(path string) *cfg {
|
|||
Key: &key.PrivateKey,
|
||||
}),
|
||||
persistate: persistate,
|
||||
|
||||
ownerIDFromKey: ownerIDFromKey,
|
||||
}
|
||||
|
||||
user.IDFromKey(&c.ownerIDFromKey, key.PrivateKey.PublicKey)
|
||||
|
||||
if metricsconfig.Address(c.appCfg) != "" {
|
||||
c.metricsCollector = metrics.NewStorageMetrics()
|
||||
netState.metrics = c.metricsCollector
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -557,7 +557,7 @@ type morphContainerReader struct {
|
|||
get containerCore.Source
|
||||
|
||||
lister interface {
|
||||
List(*owner.ID) ([]*cid.ID, error)
|
||||
List(*user.ID) ([]*cid.ID, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ func (x *morphContainerReader) GetEACL(id *cid.ID) (*eaclSDK.Table, error) {
|
|||
return x.eacl.GetEACL(id)
|
||||
}
|
||||
|
||||
func (x *morphContainerReader) List(id *owner.ID) ([]*cid.ID, error) {
|
||||
func (x *morphContainerReader) List(id *user.ID) ([]*cid.ID, error) {
|
||||
return x.lister.List(id)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ import (
|
|||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -124,8 +124,8 @@ func (i *delNetInfo) TombstoneLifetime() (uint64, error) {
|
|||
// returns node owner ID calculated from configured private key.
|
||||
//
|
||||
// Implements method needed for Object.Delete service.
|
||||
func (i *delNetInfo) LocalNodeID() *owner.ID {
|
||||
return i.cfg.ownerIDFromKey
|
||||
func (i *delNetInfo) LocalNodeID() *user.ID {
|
||||
return &i.cfg.ownerIDFromKey
|
||||
}
|
||||
|
||||
type innerRingFetcherWithNotary struct {
|
||||
|
|
|
@ -15,12 +15,12 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage/persistent"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage/temporary"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
)
|
||||
|
||||
type sessionStorage interface {
|
||||
Create(ctx context.Context, body *session.CreateRequestBody) (*session.CreateResponseBody, error)
|
||||
Get(ownerID *owner.ID, tokenID []byte) *storage.PrivateToken
|
||||
Get(ownerID *user.ID, tokenID []byte) *storage.PrivateToken
|
||||
RemoveOld(epoch uint64)
|
||||
|
||||
Close() error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue