2020-07-24 13:54:03 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2020-07-24 13:54:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// AddPeerArgs groups the arguments
|
|
|
|
// of add peer invocation call.
|
|
|
|
type AddPeerArgs struct {
|
2020-09-08 09:37:53 +00:00
|
|
|
info []byte
|
2021-11-10 10:44:19 +00:00
|
|
|
|
|
|
|
client.InvokePrmOptional
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetInfo sets the peer information.
|
2020-09-08 09:37:53 +00:00
|
|
|
func (a *AddPeerArgs) SetInfo(v []byte) {
|
2020-07-24 13:54:03 +00:00
|
|
|
a.info = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddPeer invokes the call of add peer method
|
|
|
|
// of NeoFS Netmap contract.
|
|
|
|
func (c *Client) AddPeer(args AddPeerArgs) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
|
|
|
|
|
|
|
prm.SetMethod(c.addPeerMethod)
|
|
|
|
prm.SetArgs(args.info)
|
2021-11-10 10:44:19 +00:00
|
|
|
prm.InvokePrmOptional = args.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
if err := c.client.Invoke(prm); err != nil {
|
2021-05-18 08:12:51 +00:00
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", c.addPeerMethod, err)
|
|
|
|
}
|
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|