Skip to content

Commit 7e64a78

Browse files
committed
fix logic
1 parent ba627eb commit 7e64a78

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

rollup/internal/controller/blob_uploader/blob_uploader.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,30 @@ func (b *BlobUploader) GetFirstUnuploadedBatchByPlatform(ctx context.Context, st
219219

220220
// to check if the parent batch uploaded
221221
// if no, there is a batch revert happened, we need to fallback to upload previous batch
222-
if batchIndex > 0 {
223-
fields := map[string]interface{}{
224-
"batch_index = ?": batchIndex - 1,
225-
"batch_hash = ?": batch.ParentBatchHash,
226-
"platform = ?": platform,
227-
"status = ?": types.BlobUploadStatusUploaded,
228-
}
229-
blobUpload, err := b.blobUploadOrm.GetBlobUploads(ctx, fields, nil, 1)
230-
if err != nil {
231-
return nil, err
232-
}
233-
234-
if len(blobUpload) == 0 {
235-
batchIndex--
236-
continue
237-
}
222+
// skip the check if the parent batch is genesis batch
223+
if batchIndex <= 1 {
224+
break
225+
}
226+
fields := map[string]interface{}{
227+
"batch_index = ?": batchIndex - 1,
228+
"batch_hash = ?": batch.ParentBatchHash,
229+
"platform = ?": platform,
230+
"status = ?": types.BlobUploadStatusUploaded,
231+
}
232+
blobUpload, err := b.blobUploadOrm.GetBlobUploads(ctx, fields, nil, 1)
233+
if err != nil {
234+
return nil, err
235+
}
236+
237+
if len(blobUpload) == 0 {
238+
batchIndex--
239+
continue
238240
}
239241

240242
break
241243
}
242244

243-
if batchIndex > 0 && len(batch.CommitTxHash) == 0 {
245+
if len(batch.CommitTxHash) == 0 {
244246
log.Debug("got batch not committed for blob uploading", "batch_index", batchIndex, "platform", platform.String())
245247
return nil, nil
246248
}

0 commit comments

Comments
 (0)