forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
104
pkg/morph/client/netmap/add_peer.go
Normal file
104
pkg/morph/client/netmap/add_peer.go
Normal file
|
@ -0,0 +1,104 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// PeerInfo groups the parameters of
|
||||
// new NeoFS peer.
|
||||
type PeerInfo struct {
|
||||
address []byte // peer network address in a binary format
|
||||
|
||||
key []byte // peer public key
|
||||
|
||||
opts [][]byte // binary peer options
|
||||
}
|
||||
|
||||
// AddPeerArgs groups the arguments
|
||||
// of add peer invocation call.
|
||||
type AddPeerArgs struct {
|
||||
info PeerInfo // peer information
|
||||
}
|
||||
|
||||
const addPeerFixedArgNumber = 2
|
||||
|
||||
// Address returns the peer network address
|
||||
// in a binary format.
|
||||
//
|
||||
// Address format is dictated by application
|
||||
// architecture.
|
||||
func (a PeerInfo) Address() []byte {
|
||||
return a.address
|
||||
}
|
||||
|
||||
// SetAddress sets the peer network address
|
||||
// in a binary format.
|
||||
//
|
||||
// Address format is dictated by application
|
||||
// architecture.
|
||||
func (a *PeerInfo) SetAddress(v []byte) {
|
||||
a.address = v
|
||||
}
|
||||
|
||||
// PublicKey returns the peer public key
|
||||
// in a binary format.
|
||||
//
|
||||
// Key format is dictated by application
|
||||
// architecture.
|
||||
func (a PeerInfo) PublicKey() []byte {
|
||||
return a.key
|
||||
}
|
||||
|
||||
// SetPublicKey sets the peer public key
|
||||
// in a binary format.
|
||||
//
|
||||
// Key format is dictated by application
|
||||
// architecture.
|
||||
func (a *PeerInfo) SetPublicKey(v []byte) {
|
||||
a.key = v
|
||||
}
|
||||
|
||||
// Options returns the peer options
|
||||
// in a binary format.
|
||||
//
|
||||
// Option format is dictated by application
|
||||
// architecture.
|
||||
func (a PeerInfo) Options() [][]byte {
|
||||
return a.opts
|
||||
}
|
||||
|
||||
// SetOptions sets the peer options
|
||||
// in a binary format.
|
||||
//
|
||||
// Option format is dictated by application
|
||||
// architecture.
|
||||
func (a *PeerInfo) SetOptions(v [][]byte) {
|
||||
a.opts = v
|
||||
}
|
||||
|
||||
// SetInfo sets the peer information.
|
||||
func (a *AddPeerArgs) SetInfo(v PeerInfo) {
|
||||
a.info = v
|
||||
}
|
||||
|
||||
// AddPeer invokes the call of add peer method
|
||||
// of NeoFS Netmap contract.
|
||||
func (c *Client) AddPeer(args AddPeerArgs) error {
|
||||
info := args.info
|
||||
|
||||
invokeArgs := make([]interface{}, 0, addPeerFixedArgNumber+len(info.opts))
|
||||
|
||||
invokeArgs = append(invokeArgs,
|
||||
info.address,
|
||||
info.key,
|
||||
)
|
||||
|
||||
for i := range info.opts {
|
||||
invokeArgs = append(invokeArgs, info.opts[i])
|
||||
}
|
||||
|
||||
return errors.Wrapf(c.client.Invoke(
|
||||
c.addPeerMethod,
|
||||
invokeArgs...,
|
||||
), "could not invoke method (%s)", c.addPeerMethod)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue