From 27dddb4d50c4d040926c5115c25e721a18e8822b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 1 Sep 2023 16:00:53 +0300 Subject: [PATCH] native: refactor argument of NEO's getCommitteeMembers function No funcional changes, just refactoring. It doesn't need the whole cache, only the set of committee keys with votes. Signed-off-by: Anna Shaleva --- pkg/core/native/native_neo.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 324d7a18b..923b50f11 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -363,7 +363,7 @@ func (n *NEO) initConfigCache(cfg config.ProtocolConfiguration) error { func (n *NEO) updateCache(cache *NeoCache, cvs keysWithVotes, blockHeight uint32) error { cache.committee = cvs - var committee = getCommitteeMembers(cache) + var committee = getCommitteeMembers(cache.committee) script, err := smartcontract.CreateMajorityMultiSigRedeemScript(committee.Copy()) if err != nil { return err @@ -431,7 +431,7 @@ func (n *NEO) OnPersist(ic *interop.Context) error { func (n *NEO) PostPersist(ic *interop.Context) error { gas := n.GetGASPerBlock(ic.DAO, ic.Block.Index) cache := ic.DAO.GetROCache(n.ID).(*NeoCache) - pubs := getCommitteeMembers(cache) + pubs := getCommitteeMembers(cache.committee) committeeSize := n.cfg.GetCommitteeSize(ic.Block.Index) index := int(ic.Block.Index) % committeeSize committeeReward := new(big.Int).Mul(gas, bigCommitteeRewardRatio) @@ -1137,11 +1137,10 @@ func (n *NEO) modifyVoterTurnout(d *dao.Simple, amount *big.Int) error { // GetCommitteeMembers returns public keys of nodes in committee using cached value. func (n *NEO) GetCommitteeMembers(d *dao.Simple) keys.PublicKeys { cache := d.GetROCache(n.ID).(*NeoCache) - return getCommitteeMembers(cache) + return getCommitteeMembers(cache.committee) } -func getCommitteeMembers(cache *NeoCache) keys.PublicKeys { - var cvs = cache.committee +func getCommitteeMembers(cvs keysWithVotes) keys.PublicKeys { var committee = make(keys.PublicKeys, len(cvs)) var err error for i := range committee {