[#43] cmd/neofs-node: Use morph wrappers as data sources

Morph wrappers are being uses as sources for containers and
snapshots of network map.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-09-24 10:46:47 +03:00
parent 1914b4dbad
commit 8585e147d0
3 changed files with 30 additions and 21 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap" netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
nmwrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage" tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
@ -108,6 +109,7 @@ type cfgContainer struct {
type cfgNetmap struct { type cfgNetmap struct {
scriptHash util.Uint160 scriptHash util.Uint160
wrapper *nmwrapper.Wrapper
fee util.Fixed8 fee util.Fixed8
} }

View file

@ -5,6 +5,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/session" "github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
containerTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc" containerTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc"
containerService "github.com/nspcc-dev/neofs-node/pkg/services/container" containerService "github.com/nspcc-dev/neofs-node/pkg/services/container"
containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph" containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph"
@ -21,6 +22,11 @@ func initContainerService(c *cfg) {
cnrClient, err := container.New(staticClient) cnrClient, err := container.New(staticClient)
fatalOnErr(err) fatalOnErr(err)
wrap, err := wrapper.New(cnrClient)
fatalOnErr(err)
c.cfgObject.cnrStorage = wrap // use RPC node as source of containers
metaHdr := new(session.ResponseMetaHeader) metaHdr := new(session.ResponseMetaHeader)
xHdr := new(session.XHeader) xHdr := new(session.XHeader)
xHdr.SetKey("test X-Header key") xHdr.SetKey("test X-Header key")

View file

@ -14,10 +14,7 @@ func initMorphComponents(c *cfg) {
c.cfgMorph.client, err = client.New(c.key, c.viper.GetString(cfgMorphRPCAddress)) c.cfgMorph.client, err = client.New(c.key, c.viper.GetString(cfgMorphRPCAddress))
fatalOnErr(err) fatalOnErr(err)
}
func bootstrapNode(c *cfg) {
if c.cfgNodeInfo.bootType == StorageNode {
staticClient, err := client.NewStatic( staticClient, err := client.NewStatic(
c.cfgMorph.client, c.cfgMorph.client,
c.cfgNetmap.scriptHash, c.cfgNetmap.scriptHash,
@ -26,17 +23,21 @@ func bootstrapNode(c *cfg) {
fatalOnErr(err) fatalOnErr(err)
cli, err := netmap.New(staticClient) cli, err := netmap.New(staticClient)
fatalOnErr(errors.Wrap(err, "bootstrap error")) fatalOnErr(err)
cliWrapper, err := wrapper.New(cli) wrap, err := wrapper.New(cli)
fatalOnErr(errors.Wrap(err, "bootstrap error")) fatalOnErr(err)
c.cfgObject.netMapStorage = wrap
c.cfgNetmap.wrapper = wrap
}
func bootstrapNode(c *cfg) {
peerInfo := new(v2netmap.NodeInfo) peerInfo := new(v2netmap.NodeInfo)
peerInfo.SetAddress(c.viper.GetString(cfgBootstrapAddress)) peerInfo.SetAddress(c.localAddr.String())
peerInfo.SetPublicKey(crypto.MarshalPublicKey(&c.key.PublicKey)) peerInfo.SetPublicKey(crypto.MarshalPublicKey(&c.key.PublicKey))
peerInfo.SetAttributes(c.cfgNodeInfo.attributes) peerInfo.SetAttributes(c.cfgNodeInfo.attributes)
err = cliWrapper.AddPeer(peerInfo) err := c.cfgNetmap.wrapper.AddPeer(peerInfo)
fatalOnErr(errors.Wrap(err, "bootstrap error")) fatalOnErr(errors.Wrap(err, "bootstrap error"))
}
} }