[#1101] *: Adopt interface changes of API client from SDK library

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-01-21 19:53:06 +03:00 committed by Alex Vanin
parent 674f520da7
commit 4f3323f084
14 changed files with 94 additions and 246 deletions

View file

@ -3,7 +3,6 @@ package internal
import (
"context"
"io"
"math"
"github.com/nspcc-dev/neofs-sdk-go/accounting"
"github.com/nspcc-dev/neofs-sdk-go/client"
@ -18,12 +17,12 @@ import (
// BalanceOfPrm groups parameters of BalanceOf operation.
type BalanceOfPrm struct {
commonPrm
ownerIDPrm
client.GetBalancePrm
}
// BalanceOfRes groups resulting values of BalanceOf operation.
type BalanceOfRes struct {
cliRes *client.BalanceOfRes
cliRes *client.GetBalanceRes
}
// Balance returns current balance.
@ -35,9 +34,7 @@ func (x BalanceOfRes) Balance() *accounting.Decimal {
//
// Returns any error prevented the operation from completing correctly in error return.
func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.ownerID,
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.GetBalancePrm)
return
}
@ -45,7 +42,7 @@ func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
// ListContainersPrm groups parameters of ListContainers operation.
type ListContainersPrm struct {
commonPrm
ownerIDPrm
client.ContainerListPrm
}
// ListContainersRes groups resulting values of ListContainers operation.
@ -55,16 +52,14 @@ type ListContainersRes struct {
// IDList returns list of identifiers of user's containers.
func (x ListContainersRes) IDList() []*cid.ID {
return x.cliRes.IDList()
return x.cliRes.Containers()
}
// ListContainers requests list of NeoFS user's containers.
//
// Returns any error prevented the operation from completing correctly in error return.
func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ownerID,
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ContainerListPrm)
return
}
@ -72,14 +67,7 @@ func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
// PutContainerPrm groups parameters of PutContainer operation.
type PutContainerPrm struct {
commonPrm
sessionTokenPrm
cnr *container.Container
}
// SetContainer sets container structure.
func (x *PutContainerPrm) SetContainer(cnr *container.Container) {
x.cnr = cnr
client.ContainerPutPrm
}
// PutContainerRes groups resulting values of PutContainer operation.
@ -101,10 +89,7 @@ func (x PutContainerRes) ID() *cid.ID {
//
// Returns any error prevented the operation from completing correctly in error return.
func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
res.cliRes, err = prm.cli.PutContainer(context.Background(), prm.cnr,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
)
res.cliRes, err = prm.cli.PutContainer(context.Background(), prm.ContainerPutPrm)
return
}
@ -112,7 +97,12 @@ func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
// GetContainerPrm groups parameters of GetContainer operation.
type GetContainerPrm struct {
commonPrm
containerIDPrm
cliPrm client.ContainerGetPrm
}
// SetContainer sets identifier of the container to be read.
func (x *GetContainerPrm) SetContainer(id cid.ID) {
x.cliPrm.SetContainer(id)
}
// GetContainerRes groups resulting values of GetContainer operation.
@ -129,9 +119,7 @@ func (x GetContainerRes) Container() *container.Container {
//
// Returns any error prevented the operation from completing correctly in error return.
func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cnrID,
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cliPrm)
return
}
@ -139,8 +127,7 @@ func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
// DeleteContainerPrm groups parameters of DeleteContainerPrm operation.
type DeleteContainerPrm struct {
commonPrm
sessionTokenPrm
containerIDPrm
client.ContainerDeletePrm
}
// DeleteContainerRes groups resulting values of DeleteContainer operation.
@ -155,10 +142,7 @@ type DeleteContainerRes struct{}
//
// Returns any error prevented the operation from completing correctly in error return.
func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
_, err = prm.cli.DeleteContainer(context.Background(), prm.cnrID,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
)
_, err = prm.cli.DeleteContainer(context.Background(), prm.ContainerDeletePrm)
return
}
@ -166,7 +150,7 @@ func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error)
// EACLPrm groups parameters of EACL operation.
type EACLPrm struct {
commonPrm
containerIDPrm
client.EACLPrm
}
// EACLRes groups resulting values of EACL operation.
@ -183,9 +167,7 @@ func (x EACLRes) EACL() *eacl.Table {
//
// Returns any error prevented the operation from completing correctly in error return.
func EACL(prm EACLPrm) (res EACLRes, err error) {
res.cliRes, err = prm.cli.EACL(context.Background(), prm.cnrID,
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.EACL(context.Background(), prm.EACLPrm)
return
}
@ -193,14 +175,7 @@ func EACL(prm EACLPrm) (res EACLRes, err error) {
// SetEACLPrm groups parameters of SetEACL operation.
type SetEACLPrm struct {
commonPrm
sessionTokenPrm
eaclTable *eacl.Table
}
// SetEACLTable sets eACL table structure.
func (x *SetEACLPrm) SetEACLTable(table *eacl.Table) {
x.eaclTable = table
client.SetEACLPrm
}
// SetEACLRes groups resulting values of SetEACL operation.
@ -215,10 +190,7 @@ type SetEACLRes struct{}
//
// Returns any error prevented the operation from completing correctly in error return.
func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
_, err = prm.cli.SetEACL(context.Background(), prm.eaclTable,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
)
_, err = prm.cli.SetEACL(context.Background(), prm.SetEACLPrm)
return
}
@ -226,6 +198,7 @@ func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
// NetworkInfoPrm groups parameters of NetworkInfo operation.
type NetworkInfoPrm struct {
commonPrm
client.NetworkInfoPrm
}
// NetworkInfoRes groups resulting values of NetworkInfo operation.
@ -242,9 +215,7 @@ func (x NetworkInfoRes) NetworkInfo() *netmap.NetworkInfo {
//
// Returns any error prevented the operation from completing correctly in error return.
func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
res.cliRes, err = prm.cli.NetworkInfo(context.Background(),
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.NetworkInfo(context.Background(), prm.NetworkInfoPrm)
return
}
@ -252,6 +223,7 @@ func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
// NodeInfoPrm groups parameters of NodeInfo operation.
type NodeInfoPrm struct {
commonPrm
client.EndpointInfoPrm
}
// NodeInfoRes groups resulting values of NodeInfo operation.
@ -261,21 +233,19 @@ type NodeInfoRes struct {
// NodeInfo returns information about the node from netmap.
func (x NodeInfoRes) NodeInfo() *netmap.NodeInfo {
return x.cliRes.Info().NodeInfo()
return x.cliRes.NodeInfo()
}
// LatestVersion returns latest NeoFS API version in use.
func (x NodeInfoRes) LatestVersion() *version.Version {
return x.cliRes.Info().LatestVersion()
return x.cliRes.LatestVersion()
}
// NodeInfo requests information about the remote server from NeoFS netmap.
//
// Returns any error prevented the operation from completing correctly in error return.
func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
res.cliRes, err = prm.cli.EndpointInfo(context.Background(),
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.EndpointInfo(context.Background(), prm.EndpointInfoPrm)
return
}
@ -283,6 +253,7 @@ func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
// CreateSessionPrm groups parameters of CreateSession operation.
type CreateSessionPrm struct {
commonPrm
client.CreateSessionPrm
}
// CreateSessionRes groups resulting values of CreateSession operation.
@ -297,16 +268,14 @@ func (x CreateSessionRes) ID() []byte {
// SessionKey returns public session key in a binary format.
func (x CreateSessionRes) SessionKey() []byte {
return x.cliRes.SessionKey()
return x.cliRes.PublicKey()
}
// CreateSession opens new unlimited session with the remote node.
//
// Returns any error prevented the operation from completing correctly in error return.
func CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
res.cliRes, err = prm.cli.CreateSession(context.Background(), math.MaxUint64,
client.WithKey(prm.privKey),
)
res.cliRes, err = prm.cli.CreateSession(context.Background(), prm.CreateSessionPrm)
return
}
@ -350,7 +319,6 @@ func PutObject(prm PutObjectPrm) (res PutObjectRes, err error) {
putPrm.WithPayloadReader(prm.rdr)
res.cliRes, err = prm.cli.PutObject(context.Background(), &putPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -383,7 +351,6 @@ func DeleteObject(prm DeleteObjectPrm) (res DeleteObjectRes, err error) {
delPrm.WithAddress(prm.objAddr)
res.cliRes, err = prm.cli.DeleteObject(context.Background(), &delPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -423,7 +390,6 @@ func GetObject(prm GetObjectPrm) (res GetObjectRes, err error) {
getPrm.WithRawFlag(prm.raw)
res.cliRes, err = prm.cli.GetObject(context.Background(), &getPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -472,7 +438,6 @@ func HeadObject(prm HeadObjectPrm) (res HeadObjectRes, err error) {
}
res.cliRes, err = prm.cli.HeadObject(context.Background(), &cliPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -513,7 +478,6 @@ func SearchObjects(prm SearchObjectsPrm) (res SearchObjectsRes, err error) {
cliPrm.WithContainerID(prm.cnrID)
res.cliRes, err = prm.cli.SearchObjects(context.Background(), &cliPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -574,7 +538,6 @@ func HashPayloadRanges(prm HashPayloadRangesPrm) (res HashPayloadRangesRes, err
}
res.cliRes, err = prm.cli.HashObjectPayloadRanges(context.Background(), &cliPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)
@ -615,7 +578,6 @@ func PayloadRange(prm PayloadRangePrm) (res PayloadRangeRes, err error) {
cliPrm.WithRange(prm.rng)
_, err = prm.cli.ObjectPayloadRangeData(context.Background(), &cliPrm, append(prm.opts,
client.WithKey(prm.privKey),
client.WithSession(prm.sessionToken),
client.WithBearer(prm.bearerToken),
)...)

View file

@ -1,13 +1,11 @@
package internal
import (
"crypto/ecdsa"
"io"
"github.com/nspcc-dev/neofs-sdk-go/client"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/token"
)
@ -16,8 +14,6 @@ import (
type commonPrm struct {
cli *client.Client
privKey *ecdsa.PrivateKey
}
// SetClient sets base client for NeoFS API communication.
@ -25,20 +21,6 @@ func (x *commonPrm) SetClient(cli *client.Client) {
x.cli = cli
}
// SetKey sets private key to sign the request(s).
func (x *commonPrm) SetKey(key *ecdsa.PrivateKey) {
x.privKey = key
}
type ownerIDPrm struct {
ownerID *owner.ID
}
// SetOwner sets identifier of NeoFS user.
func (x *ownerIDPrm) SetOwner(id *owner.ID) {
x.ownerID = id
}
type containerIDPrm struct {
cnrID *cid.ID
}

View file

@ -50,7 +50,7 @@ var accountingBalanceCmd = &cobra.Command{
var prm internalclient.BalanceOfPrm
prepareAPIClientWithKey(cmd, key, &prm)
prm.SetOwner(oid)
prm.SetAccount(*oid)
res, err := internalclient.BalanceOf(prm)
exitOnErr(cmd, errf("rpc error: %w", err))

View file

@ -125,7 +125,7 @@ var listContainersCmd = &cobra.Command{
var prm internalclient.ListContainersPrm
prepareAPIClientWithKey(cmd, key, &prm)
prm.SetOwner(oid)
prm.SetAccount(*oid)
res, err := internalclient.ListContainers(prm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -161,22 +161,35 @@ It will be stored in sidechain when inner ring will accepts it.`,
tok, err := getSessionToken(sessionTokenPath)
exitOnErr(cmd, err)
key, err := getKey()
exitOnErr(cmd, err)
var idOwner *owner.ID
if idOwner = tok.OwnerID(); idOwner == nil {
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
}
cnr := container.New()
cnr.SetVersion(versionSDK.Current())
cnr.SetPlacementPolicy(placementPolicy)
cnr.SetBasicACL(basicACL)
cnr.SetAttributes(attributes)
cnr.SetNonceUUID(nonce)
cnr.SetSessionToken(tok)
cnr.SetOwnerID(tok.OwnerID())
cnr.SetOwnerID(idOwner)
var (
putPrm internalclient.PutContainerPrm
getPrm internalclient.GetContainerPrm
)
prepareAPIClient(cmd, &putPrm, &getPrm)
putPrm.SetContainer(cnr)
putPrm.SetSessionToken(tok)
prepareAPIClientWithKey(cmd, key, &putPrm, &getPrm)
putPrm.SetContainer(*cnr)
if tok != nil {
putPrm.SetSessionToken(*tok)
}
res, err := internalclient.PutContainer(putPrm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -188,7 +201,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
if containerAwait {
cmd.Println("awaiting...")
getPrm.SetContainerID(id)
getPrm.SetContainer(*id)
for i := 0; i < awaitTimeout; i++ {
time.Sleep(1 * time.Second)
@ -223,8 +236,11 @@ Only owner of the container has a permission to remove container.`,
)
prepareAPIClient(cmd, &delPrm, &getPrm)
delPrm.SetContainerID(id)
delPrm.SetSessionToken(tok)
delPrm.SetContainer(*id)
if tok != nil {
delPrm.SetSessionToken(*tok)
}
_, err = internalclient.DeleteContainer(delPrm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -234,7 +250,7 @@ Only owner of the container has a permission to remove container.`,
if containerAwait {
cmd.Println("awaiting...")
getPrm.SetContainerID(id)
getPrm.SetContainer(*id)
for i := 0; i < awaitTimeout; i++ {
time.Sleep(1 * time.Second)
@ -301,7 +317,7 @@ var getContainerInfoCmd = &cobra.Command{
var prm internalclient.GetContainerPrm
prepareAPIClient(cmd, &prm)
prm.SetContainerID(id)
prm.SetContainer(*id)
res, err := internalclient.GetContainer(prm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -342,7 +358,7 @@ var getExtendedACLCmd = &cobra.Command{
var eaclPrm internalclient.EACLPrm
prepareAPIClient(cmd, &eaclPrm)
eaclPrm.SetContainerID(id)
eaclPrm.SetContainer(*id)
res, err := internalclient.EACL(eaclPrm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -405,8 +421,11 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
)
prepareAPIClient(cmd, &setEACLPrm, &getEACLPrm)
setEACLPrm.SetSessionToken(tok)
setEACLPrm.SetEACLTable(eaclTable)
setEACLPrm.SetTable(*eaclTable)
if tok != nil {
setEACLPrm.SetSessionToken(*tok)
}
_, err = internalclient.SetEACL(setEACLPrm)
exitOnErr(cmd, errf("rpc error: %w", err))
@ -417,7 +436,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
cmd.Println("awaiting...")
getEACLPrm.SetContainerID(id)
getEACLPrm.SetContainer(*id)
for i := 0; i < awaitTimeout; i++ {
time.Sleep(1 * time.Second)

View file

@ -303,7 +303,6 @@ func getEndpointAddress(endpointFlag string) (addr network.Address, err error) {
type clientWithKey interface {
SetClient(*client.Client)
SetKey(*ecdsa.PrivateKey)
}
// reads private key from command args and call prepareAPIClientWithKey with it.
@ -321,7 +320,6 @@ func prepareAPIClientWithKey(cmd *cobra.Command, key *ecdsa.PrivateKey, dst ...c
for _, d := range dst {
d.SetClient(cli)
d.SetKey(key)
}
}

View file

@ -301,6 +301,7 @@ func initCfg(path string) *cfg {
},
clientCache: cache.NewSDKClientCache(
apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)),
apiclient.WithDefaultPrivateKey(&key.PrivateKey),
),
persistate: persistate,

View file

@ -279,20 +279,17 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
return &remoteLoadAnnounceWriterProvider{
client: c,
key: r.key,
}, nil
}
type remoteLoadAnnounceWriterProvider struct {
client client.Client
key *ecdsa.PrivateKey
}
func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (loadcontroller.Writer, error) {
return &remoteLoadAnnounceWriter{
ctx: ctx,
client: p.client,
key: p.key,
}, nil
}
@ -300,7 +297,6 @@ type remoteLoadAnnounceWriter struct {
ctx context.Context
client client.Client
key *ecdsa.PrivateKey
buf []containerSDK.UsedSpaceAnnouncement
}
@ -312,7 +308,11 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.UsedSpaceAnnouncement) err
}
func (r *remoteLoadAnnounceWriter) Close() error {
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, r.buf, apiClient.WithKey(r.key))
var cliPrm apiClient.AnnounceSpacePrm
cliPrm.SetValues(r.buf)
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, cliPrm)
return err
}

View file

@ -98,7 +98,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
p.SetPrivateKey(rtp.key)
p.SetEpoch(rtp.eiCtx.Epoch())
p.SetIteration(rtp.eiCtx.I())
p.SetTrust(apiPeerToPeerTrust)
p.SetTrust(*apiPeerToPeerTrust)
_, err := internalclient.AnnounceIntermediate(p)

View file

@ -52,8 +52,8 @@ func (x *AnnounceLocalPrm) SetEpoch(epoch uint64) {
}
// SetTrusts sets list of local trust values.
func (x *AnnounceLocalPrm) SetTrusts(ts []*reputation.Trust) {
x.cliPrm.SetTrusts(ts)
func (x *AnnounceLocalPrm) SetTrusts(ts []reputation.Trust) {
x.cliPrm.SetValues(ts)
}
// AnnounceLocalRes groups resulting values of AnnounceLocal operation.
@ -67,7 +67,7 @@ type AnnounceLocalRes struct{}
func AnnounceLocal(prm AnnounceLocalPrm) (res AnnounceLocalRes, err error) {
var cliRes *client.AnnounceLocalTrustRes
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm, prm.opts...)
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(cliRes.Status())
@ -94,8 +94,8 @@ func (x *AnnounceIntermediatePrm) SetIteration(iter uint32) {
}
// SetTrust sets current global trust value computed at the iteration.
func (x *AnnounceIntermediatePrm) SetTrust(t *reputation.PeerToPeerTrust) {
x.cliPrm.SetTrust(t)
func (x *AnnounceIntermediatePrm) SetTrust(t reputation.PeerToPeerTrust) {
x.cliPrm.SetCurrentValue(t)
}
// AnnounceIntermediateRes groups resulting values of AnnounceIntermediate operation.
@ -110,7 +110,7 @@ type AnnounceIntermediateRes struct{}
func AnnounceIntermediate(prm AnnounceIntermediatePrm) (res AnnounceIntermediateRes, err error) {
var cliRes *client.AnnounceIntermediateTrustRes
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm, prm.opts...)
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm)
if err == nil {
// pull out an error from status
err = apistatus.ErrFromStatus(cliRes.Status())

View file

@ -67,7 +67,7 @@ type RemoteTrustWriter struct {
client coreclient.Client
key *ecdsa.PrivateKey
buf []*reputationapi.Trust
buf []reputationapi.Trust
}
func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
@ -79,7 +79,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
apiTrust.SetValue(t.Value().Float64())
apiTrust.SetPeer(apiPeer)
rtp.buf = append(rtp.buf, apiTrust)
rtp.buf = append(rtp.buf, *apiTrust)
return nil
}

5
go.mod
View file

@ -13,8 +13,8 @@ require (
github.com/multiformats/go-multiaddr v0.4.0
github.com/nspcc-dev/hrw v1.0.9
github.com/nspcc-dev/neo-go v0.98.0
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220121080144-596774ce5bd3
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220127135316-32dd0bb3f9c5
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220201140258-9414f42aa349
github.com/nspcc-dev/tzhash v1.5.1
github.com/panjf2000/ants/v2 v2.4.0
github.com/paulmach/orb v0.2.2
@ -33,4 +33,3 @@ require (
// Used for debug reasons
// replace github.com/nspcc-dev/neofs-api-go => ../neofs-api-go
// replace github.com/nspcc-dev/neofs-sdk-go => ../neofs-sdk-go

8
go.sum
View file

@ -365,15 +365,15 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:
github.com/nspcc-dev/neo-go v0.98.0 h1:yyW4sgY88/pLf0949qmgfkQXzRKC3CI/WyhqXNnwMd8=
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac h1:65C4z7pybLT2HjtY96abZj6kbgVp34AbrApn5DD+ZxY=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220127135316-32dd0bb3f9c5 h1:y9tbmUYhcr052QXsa4/IfUKAi2cx3TGDsEZUAow3P/Y=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220127135316-32dd0bb3f9c5/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=
github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220121080144-596774ce5bd3 h1:Llot/7cnQwCfhSrnNLDhuYxKpX4Ay+xa6x7B1jI2eaU=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220121080144-596774ce5bd3/go.mod h1:fhs4v6uts7bEgwYP05NXbAQlQ0YhK4WVjJRKQKFKBxY=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220201140258-9414f42aa349 h1:dnaLvUnqt1LUKDepsH0knjAQ92I4L+CxuW44XeVl9J8=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220201140258-9414f42aa349/go.mod h1:dPvrJlIgoF1hLJlOWgbNmxQwANsQI/8dTe/wfjxwy04=
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=

View file

@ -7,29 +7,12 @@ import (
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/nspcc-dev/neofs-sdk-go/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/owner"
)
// Client is an interface of NeoFS storage
// node's client.
type Client interface {
GetBalance(context.Context, *owner.ID, ...client.CallOption) (*client.BalanceOfRes, error)
PutContainer(context.Context, *container.Container, ...client.CallOption) (*client.ContainerPutRes, error)
GetContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerGetRes, error)
ListContainers(context.Context, *owner.ID, ...client.CallOption) (*client.ContainerListRes, error)
DeleteContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerDeleteRes, error)
EACL(context.Context, *cid.ID, ...client.CallOption) (*client.EACLRes, error)
SetEACL(context.Context, *eacl.Table, ...client.CallOption) (*client.SetEACLRes, error)
AnnounceContainerUsedSpace(context.Context, []container.UsedSpaceAnnouncement, ...client.CallOption) (*client.AnnounceSpaceRes, error)
EndpointInfo(context.Context, ...client.CallOption) (*client.EndpointInfoRes, error)
NetworkInfo(context.Context, ...client.CallOption) (*client.NetworkInfoRes, error)
AnnounceContainerUsedSpace(context.Context, client.AnnounceSpacePrm) (*client.AnnounceSpaceRes, error)
PutObject(context.Context, *client.PutObjectParams, ...client.CallOption) (*client.ObjectPutRes, error)
DeleteObject(context.Context, *client.DeleteObjectParams, ...client.CallOption) (*client.ObjectDeleteRes, error)
@ -39,10 +22,8 @@ type Client interface {
ObjectPayloadRangeData(context.Context, *client.RangeDataParams, ...client.CallOption) (*client.ObjectRangeRes, error)
HashObjectPayloadRanges(context.Context, *client.RangeChecksumParams, ...client.CallOption) (*client.ObjectRangeHashRes, error)
AnnounceLocalTrust(context.Context, client.AnnounceLocalTrustPrm, ...client.CallOption) (*client.AnnounceLocalTrustRes, error)
AnnounceIntermediateTrust(context.Context, client.AnnounceIntermediateTrustPrm, ...client.CallOption) (*client.AnnounceIntermediateTrustRes, error)
CreateSession(context.Context, uint64, ...client.CallOption) (*client.CreateSessionRes, error)
AnnounceLocalTrust(context.Context, client.AnnounceLocalTrustPrm) (*client.AnnounceLocalTrustRes, error)
AnnounceIntermediateTrust(context.Context, client.AnnounceIntermediateTrustPrm) (*client.AnnounceIntermediateTrustRes, error)
Raw() *rawclient.Client

View file

@ -11,10 +11,6 @@ import (
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/nspcc-dev/neofs-sdk-go/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/owner"
)
type multiClient struct {
@ -92,90 +88,9 @@ func (x *multiClient) PutObject(ctx context.Context, p *client.PutObjectParams,
return
}
func (x *multiClient) GetBalance(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.BalanceOfRes, err error) {
func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, prm client.AnnounceSpacePrm) (res *client.AnnounceSpaceRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.GetBalance(ctx, id, opts...)
return err
})
return
}
func (x *multiClient) PutContainer(ctx context.Context, cnr *container.Container, opts ...client.CallOption) (res *client.ContainerPutRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.PutContainer(ctx, cnr, opts...)
return err
})
return
}
func (x *multiClient) GetContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerGetRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.GetContainer(ctx, id, opts...)
return err
})
return
}
func (x *multiClient) ListContainers(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.ContainerListRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.ListContainers(ctx, id, opts...)
return err
})
return
}
func (x *multiClient) DeleteContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerDeleteRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.DeleteContainer(ctx, id, opts...)
return err
})
return
}
func (x *multiClient) EACL(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.EACLRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.EACL(ctx, id, opts...)
return err
})
return
}
func (x *multiClient) SetEACL(ctx context.Context, t *eacl.Table, opts ...client.CallOption) (res *client.SetEACLRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.SetEACL(ctx, t, opts...)
return err
})
return
}
func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, as []container.UsedSpaceAnnouncement, opts ...client.CallOption) (res *client.AnnounceSpaceRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceContainerUsedSpace(ctx, as, opts...)
return err
})
return
}
func (x *multiClient) EndpointInfo(ctx context.Context, opts ...client.CallOption) (res *client.EndpointInfoRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.EndpointInfo(ctx, opts...)
return err
})
return
}
func (x *multiClient) NetworkInfo(ctx context.Context, opts ...client.CallOption) (res *client.NetworkInfoRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.NetworkInfo(ctx, opts...)
res, err = c.AnnounceContainerUsedSpace(ctx, prm)
return err
})
@ -236,27 +151,18 @@ func (x *multiClient) SearchObjects(ctx context.Context, p *client.SearchObjectP
return
}
func (x *multiClient) CreateSession(ctx context.Context, exp uint64, opts ...client.CallOption) (res *client.CreateSessionRes, err error) {
func (x *multiClient) AnnounceLocalTrust(ctx context.Context, prm client.AnnounceLocalTrustPrm) (res *client.AnnounceLocalTrustRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.CreateSession(ctx, exp, opts...)
res, err = c.AnnounceLocalTrust(ctx, prm)
return err
})
return
}
func (x *multiClient) AnnounceLocalTrust(ctx context.Context, p client.AnnounceLocalTrustPrm, opts ...client.CallOption) (res *client.AnnounceLocalTrustRes, err error) {
func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, prm client.AnnounceIntermediateTrustPrm) (res *client.AnnounceIntermediateTrustRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceLocalTrust(ctx, p, opts...)
return err
})
return
}
func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, p client.AnnounceIntermediateTrustPrm, opts ...client.CallOption) (res *client.AnnounceIntermediateTrustRes, err error) {
err = x.iterateClients(ctx, func(c clientcore.Client) error {
res, err = c.AnnounceIntermediateTrust(ctx, p, opts...)
res, err = c.AnnounceIntermediateTrust(ctx, prm)
return err
})