Skip to content

Commit

Permalink
remove unnecessary sort
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Jan 9, 2024
1 parent ced400e commit b00c874
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions x/ccv/consumer/keeper/soft_opt_out.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper

import (
"bytes"
"encoding/binary"
"sort"

Expand Down Expand Up @@ -89,14 +88,9 @@ func (k Keeper) UpdateSlashingSigningInfo(ctx sdk.Context) {

// Update SigningInfo for opted out validators
valset := k.GetAllCCValidator(ctx)
// sort validators by power ascending
sort.SliceStable(valset, func(i, j int) bool {
if valset[i].Power != valset[j].Power {
return valset[i].Power < valset[j].Power
}
return bytes.Compare(valset[i].Address, valset[j].Address) < 0
})

// Note that we don't need to sort the valset as GetAllCCValidator
// uses KVStorePrefixIterator that iterates over all the keys with
// a certain prefix in ascending order
for _, val := range valset {
consAddr := sdk.ConsAddress(val.Address)
signingInfo, found := k.slashingKeeper.GetValidatorSigningInfo(ctx, consAddr)
Expand Down

0 comments on commit b00c874

Please sign in to comment.