frostfs-node/pkg/morph/client/netmap/wrapper/add_peer.go
Alex Vanin aa98592ac4 [#15] Fix wrapper for add peer contract method
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:35 +03:00

27 lines
543 B
Go

package wrapper
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 *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",
)
}