From 875a0ee6e40ee193ac8a541d46d2fec77db259a6 Mon Sep 17 00:00:00 2001 From: marston Date: Wed, 24 Jul 2024 14:21:00 -0400 Subject: [PATCH] fixing open files! --- x/storage/keeper/grpc_query_active_deals.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/x/storage/keeper/grpc_query_active_deals.go b/x/storage/keeper/grpc_query_active_deals.go index 8d761906..292b5fa9 100644 --- a/x/storage/keeper/grpc_query_active_deals.go +++ b/x/storage/keeper/grpc_query_active_deals.go @@ -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 } @@ -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++