forked from TrueCloudLab/frostfs-node
71b87155ef
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
29 lines
567 B
Go
29 lines
567 B
Go
package wrapper
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
|
)
|
|
|
|
// AddPeer registers peer in NeoFS network through
|
|
// Netmap contract call.
|
|
func (w *Wrapper) AddPeer(nodeInfo *netmap.NodeInfo) error {
|
|
if nodeInfo == nil {
|
|
return errors.New("nil node info")
|
|
}
|
|
|
|
rawNodeInfo, err := nodeInfo.Marshal()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
args := netmap.AddPeerArgs{}
|
|
args.SetInfo(rawNodeInfo)
|
|
|
|
if err := w.client.AddPeer(args); err != nil {
|
|
return fmt.Errorf("could not invoke smart contract: %w", err)
|
|
}
|
|
return nil
|
|
}
|