2020-07-24 13:54:03 +00:00
|
|
|
package wrapper
|
|
|
|
|
|
|
|
import (
|
2021-01-11 14:36:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
2020-07-24 13:54:03 +00:00
|
|
|
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UpdatePeerState changes peer status through Netmap contract
|
|
|
|
// call.
|
2021-01-11 14:36:55 +00:00
|
|
|
func (w *Wrapper) UpdatePeerState(key []byte, state netmap.NodeState) error {
|
2020-07-24 13:54:03 +00:00
|
|
|
args := contract.UpdateStateArgs{}
|
|
|
|
args.SetPublicKey(key)
|
2021-01-11 14:36:55 +00:00
|
|
|
args.SetState(int64(state.ToV2()))
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// invoke smart contract call
|
|
|
|
//
|
|
|
|
// Note: errors.Wrap returns nil on nil error arg.
|
|
|
|
return errors.Wrap(
|
|
|
|
w.client.UpdateState(args),
|
|
|
|
"could not invoke smart contract",
|
|
|
|
)
|
|
|
|
}
|