frostfs-node/pkg/morph/client/netmap/add_peer.go
Pavel Karpy c25f5a86ae [#971] morph/netmap: Add optional parameters
Add optional parameters to the client call
signature. Group parameters of a client call
into struct to improve future codebase
support.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-11-19 09:58:03 +03:00

35 lines
721 B
Go

package netmap
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
)
// AddPeerArgs groups the arguments
// of add peer invocation call.
type AddPeerArgs struct {
info []byte
client.InvokePrmOptional
}
// SetInfo sets the peer information.
func (a *AddPeerArgs) SetInfo(v []byte) {
a.info = v
}
// AddPeer invokes the call of add peer method
// of NeoFS Netmap contract.
func (c *Client) AddPeer(args AddPeerArgs) error {
prm := client.InvokePrm{}
prm.SetMethod(c.addPeerMethod)
prm.SetArgs(args.info)
prm.InvokePrmOptional = args.InvokePrmOptional
if err := c.client.Invoke(prm); err != nil {
return fmt.Errorf("could not invoke method (%s): %w", c.addPeerMethod, err)
}
return nil
}