Skip to content

Commit

Permalink
chore: improved staker sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Dec 20, 2024
1 parent 1e3c457 commit 87df706
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x/query/keeper/grpc_query_stakers_by_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ func (k Keeper) StakersByPool(c context.Context, req *types.QueryStakersByPoolRe
stakers = append(stakers, *k.GetFullStaker(ctx, valaccount.Staker))
}

sort.Slice(stakers, func(i, j int) bool {
return k.stakerKeeper.GetValidatorPoolStake(ctx, stakers[i].Address, req.PoolId) > k.stakerKeeper.GetValidatorPoolStake(ctx, stakers[j].Address, req.PoolId)
stakes := k.stakerKeeper.GetValidatorPoolStakes(ctx, req.PoolId)

sort.SliceStable(stakers, func(i, j int) bool {
return stakes[stakers[i].Address] > stakes[stakers[j].Address]
})

return &types.QueryStakersByPoolResponse{Stakers: stakers}, nil
Expand Down

0 comments on commit 87df706

Please sign in to comment.