frostfs-node/cmd/neofs-node/morph.go

41 lines
1 KiB
Go
Raw Normal View History

package main
import (
"github.com/nspcc-dev/neo-go/pkg/util"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
)
func initMorphComponents(c *cfg) {
var err error
c.cfgMorph.client, err = client.New(c.key, c.cfgMorph.endpoint)
fatalOnErr(err)
}
func bootstrapNode(c *cfg) {
if c.cfgNodeInfo.bootType == StorageNode {
u160, err := util.Uint160DecodeStringLE(c.cfgNetmap.scriptHash)
fatalOnErr(err)
staticClient, err := client.NewStatic(c.cfgMorph.client, u160, c.cfgContainer.fee)
fatalOnErr(err)
cli, err := netmap.New(staticClient)
fatalOnErr(err)
cliWrapper, err := wrapper.New(cli)
fatalOnErr(err)
peerInfo := new(netmap.NodeInfo)
peerInfo.SetAddress(c.cfgNodeInfo.address)
peerInfo.SetPublicKey(crypto.MarshalPublicKey(&c.key.PublicKey))
// todo: add attributes as opts
err = cliWrapper.AddPeer(peerInfo)
fatalOnErr(err)
}
}