[#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>
This commit is contained in:
parent
3114be39d0
commit
c25f5a86ae
11 changed files with 224 additions and 90 deletions
|
@ -3,16 +3,37 @@ package wrapper
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
)
|
||||
|
||||
// UpdatePeerPrm groups parameters of UpdatePeerState operation.
|
||||
type UpdatePeerPrm struct {
|
||||
key []byte
|
||||
state netmap.NodeState
|
||||
|
||||
client.InvokePrmOptional
|
||||
}
|
||||
|
||||
// SetKey sets public key.
|
||||
func (u *UpdatePeerPrm) SetKey(key []byte) {
|
||||
u.key = key
|
||||
}
|
||||
|
||||
// SetState sets node state.
|
||||
func (u *UpdatePeerPrm) SetState(state netmap.NodeState) {
|
||||
u.state = state
|
||||
}
|
||||
|
||||
// UpdatePeerState changes peer status through Netmap contract
|
||||
// call.
|
||||
func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error {
|
||||
func (w *Wrapper) UpdatePeerState(prm UpdatePeerPrm) error {
|
||||
args := contract.UpdateStateArgs{}
|
||||
args.SetPublicKey(key)
|
||||
args.SetState(int64(state.ToV2()))
|
||||
|
||||
args.SetPublicKey(prm.key)
|
||||
args.SetState(int64(prm.state.ToV2()))
|
||||
args.InvokePrmOptional = prm.InvokePrmOptional
|
||||
|
||||
// invoke smart contract call
|
||||
if err := w.client.UpdateState(args); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue