mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
oracle/neofs: Upgrade NeoFS dependencies
Update includes: 1. New simple client mode that parses erroneous status codes as `error` and returns them from the calls of the client methods. 2. `Client` is struct now, not an interface. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
36ec602339
commit
a33779c55e
3 changed files with 21 additions and 30 deletions
3
go.mod
3
go.mod
|
@ -4,14 +4,13 @@ require (
|
|||
github.com/abiosoft/ishell/v2 v2.0.2
|
||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db
|
||||
github.com/btcsuite/btcd v0.22.0-beta
|
||||
github.com/frankban/quicktest v1.14.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/holiman/uint256 v1.2.0
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22
|
||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477
|
||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
|
|
8
go.sum
8
go.sum
|
@ -179,19 +179,23 @@ github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a/go.mod h1:/YFK+XOxx
|
|||
github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac h1:nrewxmpns7GE0nO2DyGkrYfpZd/nMF7bN7DGvT8ljp0=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20210915112629-e1b6cce73d02/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
|
||||
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
|
||||
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1 h1:CGA56mhLLduWRuMHcWujP5Ek+gAnXHk0WuIWkG65G1s=
|
||||
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.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/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 h1:JC+jt4ARpMV/L3OqPHBKxAmbMabU7RYl/L4KgBz3yPs=
|
||||
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-20220113123743-7f3162110659 h1:rpMCoRa7expLc9gMiOP724gz6YSykZzmMALR/CmiwnU=
|
||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40=
|
||||
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=
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
neofsapistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
)
|
||||
|
@ -39,21 +38,6 @@ var (
|
|||
ErrInvalidCommand = errors.New("invalid command")
|
||||
)
|
||||
|
||||
// common interface of NeoFS API client's responses.
|
||||
type neoFSResponseCommon interface {
|
||||
Status() neofsapistatus.Status
|
||||
}
|
||||
|
||||
// if err is nil, then pulls out failed statuses and returns them as error.
|
||||
// keep an eye on https://github.com/nspcc-dev/neofs-sdk-go/issues/91.
|
||||
func combineAllErrors(resp neoFSResponseCommon, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return neofsapistatus.ErrFromStatus(resp.Status())
|
||||
}
|
||||
|
||||
// Get returns neofs object from the provided url.
|
||||
// URI scheme is "neofs:<Container-ID>/<Object-ID/<Command>/<Params>".
|
||||
// If Command is not provided, full object is requested.
|
||||
|
@ -63,7 +47,11 @@ func Get(ctx context.Context, priv *keys.PrivateKey, u *url.URL, addr string) ([
|
|||
return nil, err
|
||||
}
|
||||
|
||||
c, err := client.New(client.WithDefaultPrivateKey(&priv.PrivateKey), client.WithURIAddress(addr, nil))
|
||||
c, err := client.New(
|
||||
client.WithDefaultPrivateKey(&priv.PrivateKey),
|
||||
client.WithURIAddress(addr, nil),
|
||||
client.WithNeoFSErrorParsing(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -109,15 +97,15 @@ func parseNeoFSURL(u *url.URL) (*object.Address, []string, error) {
|
|||
return objectAddr, ps[2:], nil
|
||||
}
|
||||
|
||||
func getPayload(ctx context.Context, c client.Client, addr *object.Address) ([]byte, error) {
|
||||
func getPayload(ctx context.Context, c *client.Client, addr *object.Address) ([]byte, error) {
|
||||
res, err := c.GetObject(ctx, new(client.GetObjectParams).WithAddress(addr))
|
||||
if err = combineAllErrors(res, err); err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return checkUTF8(res.Object().Payload())
|
||||
}
|
||||
|
||||
func getRange(ctx context.Context, c client.Client, addr *object.Address, ps ...string) ([]byte, error) {
|
||||
func getRange(ctx context.Context, c *client.Client, addr *object.Address, ps ...string) ([]byte, error) {
|
||||
if len(ps) == 0 {
|
||||
return nil, ErrInvalidRange
|
||||
}
|
||||
|
@ -126,24 +114,24 @@ func getRange(ctx context.Context, c client.Client, addr *object.Address, ps ...
|
|||
return nil, err
|
||||
}
|
||||
res, err := c.ObjectPayloadRangeData(ctx, new(client.RangeDataParams).WithAddress(addr).WithRange(r))
|
||||
if err = combineAllErrors(res, err); err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return checkUTF8(res.Data())
|
||||
}
|
||||
|
||||
func getHeader(ctx context.Context, c client.Client, addr *object.Address) ([]byte, error) {
|
||||
func getHeader(ctx context.Context, c *client.Client, addr *object.Address) ([]byte, error) {
|
||||
res, err := c.HeadObject(ctx, new(client.ObjectHeaderParams).WithAddress(addr))
|
||||
if err = combineAllErrors(res, err); err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Object().MarshalHeaderJSON()
|
||||
}
|
||||
|
||||
func getHash(ctx context.Context, c client.Client, addr *object.Address, ps ...string) ([]byte, error) {
|
||||
func getHash(ctx context.Context, c *client.Client, addr *object.Address, ps ...string) ([]byte, error) {
|
||||
if len(ps) == 0 || ps[0] == "" { // hash of the full payload
|
||||
res, err := c.HeadObject(ctx, new(client.ObjectHeaderParams).WithAddress(addr))
|
||||
if err = combineAllErrors(res, err); err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Object().PayloadChecksum().Sum(), nil
|
||||
|
@ -154,7 +142,7 @@ func getHash(ctx context.Context, c client.Client, addr *object.Address, ps ...s
|
|||
}
|
||||
res, err := c.HashObjectPayloadRanges(ctx,
|
||||
new(client.RangeChecksumParams).WithAddress(addr).WithRangeList(r))
|
||||
if err = combineAllErrors(res, err); err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hashes := res.Hashes()
|
||||
|
|
Loading…
Reference in a new issue