forked from TrueCloudLab/frostfs-node
[#15] Fix wrapper for add peer contract method
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
ee9551992c
commit
aa98592ac4
2 changed files with 26 additions and 10 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
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) {
|
||||
|
@ -25,17 +26,15 @@ func bootstrapNode(c *cfg) {
|
|||
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
|
||||
|
||||
rawInfo, err := peerInfo.StableMarshal(nil)
|
||||
fatalOnErr(err)
|
||||
|
||||
args := new(netmap.AddPeerArgs)
|
||||
args.SetInfo(rawInfo)
|
||||
err = cli.AddPeer(*args)
|
||||
err = cliWrapper.AddPeer(peerInfo)
|
||||
fatalOnErr(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
package wrapper
|
||||
|
||||
// NodeInfo groups information about NeoFS storage node.
|
||||
type NodeInfo struct{}
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// AddPeer registers peer in NeoFS network through
|
||||
// Netmap contract call.
|
||||
func (w *Wrapper) AddPeer(nodeInfo NodeInfo) error {
|
||||
panic("implement me")
|
||||
func (w *Wrapper) AddPeer(nodeInfo *netmap.NodeInfo) error {
|
||||
if nodeInfo == nil {
|
||||
return errors.New("nil node info")
|
||||
}
|
||||
|
||||
rawNodeInfo, err := nodeInfo.StableMarshal(nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
args := netmap.AddPeerArgs{}
|
||||
args.SetInfo(rawNodeInfo)
|
||||
|
||||
return errors.Wrap(
|
||||
w.client.AddPeer(args),
|
||||
"could not invoke smart contract",
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue