forked from TrueCloudLab/frostfs-node
[#625] client/netmap: remove intermediate wrapper
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
8c5c3ac9e8
commit
97d18bc515
36 changed files with 511 additions and 1011 deletions
|
@ -4,29 +4,37 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
)
|
||||
|
||||
// AddPeerArgs groups the arguments
|
||||
// of add peer invocation call.
|
||||
type AddPeerArgs struct {
|
||||
info []byte
|
||||
// AddPeerPrm groups parameters of AddPeer operation.
|
||||
type AddPeerPrm struct {
|
||||
nodeInfo *netmap.NodeInfo
|
||||
|
||||
client.InvokePrmOptional
|
||||
}
|
||||
|
||||
// SetInfo sets the peer information.
|
||||
func (a *AddPeerArgs) SetInfo(v []byte) {
|
||||
a.info = v
|
||||
// SetNodeInfo sets new peer NodeInfo.
|
||||
func (a *AddPeerPrm) SetNodeInfo(nodeInfo *netmap.NodeInfo) {
|
||||
a.nodeInfo = nodeInfo
|
||||
}
|
||||
|
||||
// AddPeer invokes the call of add peer method
|
||||
// of NeoFS Netmap contract.
|
||||
func (c *Client) AddPeer(args AddPeerArgs) error {
|
||||
prm := client.InvokePrm{}
|
||||
// AddPeer registers peer in NeoFS network through
|
||||
// Netmap contract call.
|
||||
func (c *Client) AddPeer(p AddPeerPrm) error {
|
||||
if p.nodeInfo == nil {
|
||||
return fmt.Errorf("nil node info (%s)", addPeerMethod)
|
||||
}
|
||||
|
||||
rawNodeInfo, err := p.nodeInfo.Marshal()
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't marshal node info (%s): %w", addPeerMethod, err)
|
||||
}
|
||||
|
||||
prm := client.InvokePrm{}
|
||||
prm.SetMethod(addPeerMethod)
|
||||
prm.SetArgs(args.info)
|
||||
prm.InvokePrmOptional = args.InvokePrmOptional
|
||||
prm.SetArgs(rawNodeInfo)
|
||||
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||
|
||||
if err := c.client.Invoke(prm); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", addPeerMethod, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue