2020-08-22 15:20:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-08-31 15:20:02 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
2020-08-22 15:20:47 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2020-08-31 15:20:02 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
2020-09-08 13:14:22 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
|
2020-08-22 15:20:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func initMorphComponents(c *cfg) {
|
|
|
|
var err error
|
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
c.cfgMorph.client, err = client.New(c.key, c.cfgMorph.endpoint)
|
2020-08-22 15:20:47 +00:00
|
|
|
fatalOnErr(err)
|
|
|
|
}
|
2020-08-31 15:20:02 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2020-09-08 13:14:22 +00:00
|
|
|
cliWrapper, err := wrapper.New(cli)
|
|
|
|
fatalOnErr(err)
|
|
|
|
|
2020-09-08 09:37:53 +00:00
|
|
|
peerInfo := new(netmap.NodeInfo)
|
2020-08-31 15:20:02 +00:00
|
|
|
peerInfo.SetAddress(c.cfgNodeInfo.address)
|
|
|
|
peerInfo.SetPublicKey(crypto.MarshalPublicKey(&c.key.PublicKey))
|
|
|
|
// todo: add attributes as opts
|
|
|
|
|
2020-09-08 13:14:22 +00:00
|
|
|
err = cliWrapper.AddPeer(peerInfo)
|
2020-08-31 15:20:02 +00:00
|
|
|
fatalOnErr(err)
|
|
|
|
}
|
|
|
|
}
|