[#104] Update neofs-api-go with new protobuf API
Also update contains JSON converters for neofs-cli and fixes bug in container.set-acl command of SDK. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9e08b41a6f
commit
e6f04f7785
7 changed files with 13 additions and 7 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
grpccontainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/policy"
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -265,7 +266,7 @@ var getContainerInfoCmd = &cobra.Command{
|
|||
|
||||
// todo: make more user friendly way to parse raw data
|
||||
msg := new(grpccontainer.Container)
|
||||
if msg.Unmarshal(data) != nil {
|
||||
if proto.Unmarshal(data, msg) != nil {
|
||||
return errors.New("can't unmarshal container")
|
||||
}
|
||||
|
||||
|
|
5
go.mod
5
go.mod
|
@ -5,7 +5,7 @@ go 1.14
|
|||
require (
|
||||
bou.ke/monkey v1.0.2
|
||||
github.com/alecthomas/participle v0.6.0
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/golang/protobuf v1.4.3
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/mr-tron/base58 v1.1.3
|
||||
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2
|
||||
github.com/multiformats/go-multihash v0.0.13 // indirect
|
||||
github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201015080537-4e6350f6d438
|
||||
github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201020123541-2aa40b0dd3a5
|
||||
github.com/nspcc-dev/neofs-crypto v0.3.0
|
||||
github.com/nspcc-dev/tzhash v1.4.0
|
||||
github.com/panjf2000/ants/v2 v2.3.0
|
||||
|
@ -33,6 +33,7 @@ require (
|
|||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
||||
golang.org/x/tools v0.0.0-20200123022218-593de606220b // indirect
|
||||
google.golang.org/grpc v1.29.1
|
||||
google.golang.org/protobuf v1.23.0
|
||||
)
|
||||
|
||||
// Used for debug reasons
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
||||
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Process add peer notification by sanity check of new node
|
||||
|
@ -20,7 +21,7 @@ func (np *Processor) processAddPeer(node []byte) {
|
|||
// unmarshal grpc (any transport) version of node info from API v2
|
||||
nodeInfo := new(netmap.NodeInfo)
|
||||
|
||||
err := nodeInfo.Unmarshal(node)
|
||||
err := proto.Unmarshal(node, nodeInfo)
|
||||
if err != nil {
|
||||
// it will be nice to have tx id at event structure to log it
|
||||
np.log.Warn("can't parse network map candidate")
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -82,7 +83,7 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
|
|||
|
||||
// convert serialized bytes into GRPC structure
|
||||
grpcMsg := new(msgContainer.Container)
|
||||
err = grpcMsg.Unmarshal(rpcAnswer.Container())
|
||||
err = proto.Unmarshal(rpcAnswer.Container(), grpcMsg)
|
||||
if err != nil {
|
||||
// use other major version if there any
|
||||
return nil, errors.Wrap(err, "can't unmarshal container")
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
msgACL "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
|
@ -30,7 +31,7 @@ func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) {
|
|||
}
|
||||
|
||||
grpcMsg := new(msgACL.EACLTable)
|
||||
err = grpcMsg.Unmarshal(rpcAnswer.EACL())
|
||||
err = proto.Unmarshal(rpcAnswer.EACL(), grpcMsg)
|
||||
if err != nil {
|
||||
// use other major version if there any
|
||||
return nil, nil, err
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
grpcNetmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// GetNetMap receives information list about storage nodes
|
||||
|
@ -26,7 +27,7 @@ func (w Wrapper) GetNetMap(diff uint64) (*netmap.Netmap, error) {
|
|||
|
||||
for _, peer := range rawPeers {
|
||||
grpcNodeInfo := new(grpcNetmap.NodeInfo) // transport representation of struct
|
||||
err = grpcNodeInfo.Unmarshal(peer)
|
||||
err = proto.Unmarshal(peer, grpcNodeInfo)
|
||||
if err != nil {
|
||||
// consider unmarshalling into different major versions
|
||||
// of NodeInfo structure, if there any
|
||||
|
|
Loading…
Reference in a new issue