notary: simplify key presence check with slices

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-08-27 12:28:51 +03:00
parent 8925b42250
commit c07604fbf3

View file

@ -1,6 +1,8 @@
package notary package notary
import ( import (
"slices"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
@ -13,12 +15,8 @@ func (n *Notary) UpdateNotaryNodes(notaryNodes keys.PublicKeys) {
n.accMtx.Lock() n.accMtx.Lock()
defer n.accMtx.Unlock() defer n.accMtx.Unlock()
if n.currAccount != nil { if n.currAccount != nil && slices.ContainsFunc(notaryNodes, n.currAccount.PublicKey().Equal) {
for _, node := range notaryNodes { return
if node.Equal(n.currAccount.PublicKey()) {
return
}
}
} }
var acc *wallet.Account var acc *wallet.Account