2020-07-24 13:54:03 +00:00
|
|
|
package wrapper
|
|
|
|
|
2020-09-08 13:14:22 +00:00
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// AddPeer registers peer in NeoFS network through
|
|
|
|
// Netmap contract call.
|
2020-09-08 13:14:22 +00:00
|
|
|
func (w *Wrapper) AddPeer(nodeInfo *netmap.NodeInfo) error {
|
|
|
|
if nodeInfo == nil {
|
|
|
|
return errors.New("nil node info")
|
|
|
|
}
|
|
|
|
|
2020-11-16 10:26:35 +00:00
|
|
|
rawNodeInfo, err := nodeInfo.Marshal()
|
2020-09-08 13:14:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
args := netmap.AddPeerArgs{}
|
|
|
|
args.SetInfo(rawNodeInfo)
|
|
|
|
|
|
|
|
return errors.Wrap(
|
|
|
|
w.client.AddPeer(args),
|
|
|
|
"could not invoke smart contract",
|
|
|
|
)
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|