[#1224] morph: Call Alphabet methods flexibly

Call `UpdateStateIR` and `AddPeerIR` method instead of `UpdateState` and
`AddPeer` if calling client is configured as Alphabet in notary enabled
environment.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-13 21:35:37 +03:00 committed by LeL
parent a129fc98da
commit 71f18ba9ec
2 changed files with 23 additions and 5 deletions

View file

@ -27,8 +27,17 @@ func (u *UpdatePeerPrm) SetState(state netmap.NodeState) {
// UpdatePeerState changes peer status through Netmap contract call.
func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
method := updateStateMethod
if c.client.WithNotary() && c.client.IsAlpha() {
// In notary environments Alphabet must calls UpdateStateIR method instead of UpdateState.
// It differs from UpdateState only by name, so we can do this in the same form.
// See https://github.com/nspcc-dev/neofs-contract/issues/225.
method += "IR"
}
prm := client.InvokePrm{}
prm.SetMethod(updateStateMethod)
prm.SetMethod(method)
prm.SetArgs(int64(p.state.ToV2()), p.key)
prm.InvokePrmOptional = p.InvokePrmOptional