From 6e863e9a060301f24543699aa1546d292dc0bd3d Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Fri, 15 Nov 2024 02:18:13 +0300 Subject: [PATCH] cli: fix fetchLatestMissingBlockIndex in `upload-bin` command Close #3667 Signed-off-by: Ekaterina Pavlova --- cli/util/upload_bin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/util/upload_bin.go b/cli/util/upload_bin.go index 4d5e387ce..390f670ed 100644 --- a/cli/util/upload_bin.go +++ b/cli/util/upload_bin.go @@ -185,7 +185,7 @@ type searchResult struct { func fetchLatestMissingBlockIndex(ctx context.Context, p *pool.Pool, containerID cid.ID, priv *keys.PrivateKey, attributeKey string, currentHeight int, maxParallelSearches, maxRetries int) (int, error) { var ( wg sync.WaitGroup - numBatches = currentHeight/searchBatchSize + 1 + numBatches = currentHeight / searchBatchSize emptyBatchFound bool ) @@ -228,12 +228,12 @@ func fetchLatestMissingBlockIndex(ctx context.Context, p *pool.Pool, containerID if results[i].err != nil { return 0, fmt.Errorf("blocks search failed for batch with indexes from %d to %d: %w", results[i].startIndex, results[i].endIndex-1, results[i].err) } - if results[i].numOIDs < searchBatchSize { + if results[i].numOIDs == 0 { emptyBatchFound = true continue } if emptyBatchFound || (batch == numBatches && i == len(results)-1) { - return results[i].startIndex + searchBatchSize, nil + return results[i].startIndex, nil } } }