Skip to content

Commit

Permalink
fixing open files! (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell authored Jul 24, 2024
2 parents ba7aee0 + 875a0ee commit b13c69d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions x/storage/keeper/grpc_query_active_deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,16 @@ func (k Keeper) OpenFiles(c context.Context, req *types.QueryOpenFiles) (*types.
var files []types.UnifiedFile
ctx := sdk.UnwrapSDKContext(c)

reverse := false
var limit uint64 = 100
if req.Pagination != nil { // HERE IS THE FIX
reverse = req.Pagination.Reverse
limit = req.Pagination.Limit
}

var i uint64
k.IterateFilesByMerkle(ctx, req.Pagination.Reverse, func(_ []byte, val []byte) bool {
if i >= req.Pagination.Limit {
k.IterateFilesByMerkle(ctx, reverse, func(_ []byte, val []byte) bool {
if i >= limit {
return true
}

Expand All @@ -155,6 +162,8 @@ func (k Keeper) OpenFiles(c context.Context, req *types.QueryOpenFiles) (*types.

if len(file.Proofs) < int(file.MaxProofs) {
files = append(files, file)
} else {
return false
}

i++
Expand Down

0 comments on commit b13c69d

Please sign in to comment.