From b3632dcd81253edf908098d285f634db9b0593e7 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 10 Mar 2021 12:24:26 +0300 Subject: [PATCH] [#421] morph/client: Add notary list update function Signed-off-by: Alex Vanin --- pkg/morph/client/notary.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 379b66a60..04c1f4635 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -3,6 +3,7 @@ package client import ( "crypto/elliptic" + "github.com/nspcc-dev/neo-go/pkg/core/native" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" @@ -45,6 +46,7 @@ const ( innerRingListMethod = "innerRingList" notaryBalanceOfMethod = "balanceOf" + setDesignateMethod = "designateAsRole" notaryBalanceErrMsg = "can't fetch notary balance" ) @@ -151,6 +153,20 @@ func (c *Client) GetNotaryDeposit() (int64, error) { return bigIntDeposit.Int64(), nil } +// UpdateNotaryList updates list of notary nodes in designate contract. Requires +// committee multi signature. +func (c *Client) UpdateNotaryList(list keys.PublicKeys) error { + if c.notary == nil { + return errNotaryNotEnabled + } + + return c.notaryInvokeAsCommittee(c.designate, + setDesignateMethod, + native.RoleP2PNotary, + list, + ) +} + // Invoke invokes contract method by sending tx to notary contract in // blockchain. Fallback tx is a `RET`. Notary support should be enabled // in client to use this function.