Skip to content

Commit

Permalink
native: refactor argument of NEO's getCommitteeMembers function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 1, 2023
1 parent 2e0f7c3 commit 1b1fad5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/core/native/native_neo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -449,7 +449,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)
Expand Down Expand Up @@ -1155,11 +1155,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 {
Expand Down

0 comments on commit 1b1fad5

Please sign in to comment.