forked from TrueCloudLab/frostfs-node
[#174] Use Marshal(JSON)/Unmarshal(JSON) methods for encoding/decoding
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3de8febe57
commit
58fcb35fb0
22 changed files with 91 additions and 140 deletions
|
@ -2,11 +2,8 @@ package wrapper
|
|||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
v2netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
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,16 +23,12 @@ func (w Wrapper) GetNetMap(diff uint64) (*netmap.Netmap, error) {
|
|||
infos := make([]netmap.NodeInfo, 0, len(rawPeers))
|
||||
|
||||
for _, peer := range rawPeers {
|
||||
grpcNodeInfo := new(grpcNetmap.NodeInfo) // transport representation of struct
|
||||
err = proto.Unmarshal(peer, grpcNodeInfo)
|
||||
if err != nil {
|
||||
// consider unmarshalling into different major versions
|
||||
// of NodeInfo structure, if there any
|
||||
nodeInfo := netmap.NewNodeInfo()
|
||||
if err := nodeInfo.Unmarshal(peer); err != nil {
|
||||
return nil, errors.Wrap(err, "can't unmarshal peer info")
|
||||
}
|
||||
|
||||
v2 := v2netmap.NodeInfoFromGRPCMessage(grpcNodeInfo)
|
||||
infos = append(infos, *netmap.NewNodeInfoFromV2(v2))
|
||||
infos = append(infos, *nodeInfo)
|
||||
}
|
||||
|
||||
nodes := netmap.NodesFromInfo(infos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue