Skip to content

Commit

Permalink
feat: shuffle the result of StorageProviders query method (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythonberg1997 committed Nov 8, 2023
1 parent 12abbd9 commit bee4346
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions x/sp/keeper/grpc_query.go
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"math/rand"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -31,6 +32,10 @@ func (k Keeper) StorageProviders(goCtx context.Context, req *types.QueryStorageP
return nil, status.Error(codes.Internal, err.Error())
}

rand.Shuffle(len(sps), func(i, j int) {
sps[i], sps[j] = sps[j], sps[i]
})

return &types.QueryStorageProvidersResponse{Sps: sps, Pagination: pageRes}, nil
}

Expand Down

0 comments on commit bee4346

Please sign in to comment.