message: indexer-agent: Avoid looping while receipts cannot be collected yet
diff: @@ -157,15 +157,17 @@ export class AllocationReceiptCollector implements ReceiptCollector {
  compare: (t1, t2) => t1.timeout - t2.timeout,
  })
  + const hasReceiptsReadyForCollecting = () => {
  + const batch = this.receiptsToCollect.peek()
  + return batch && batch.timeout <= Date.now()
  + }
  +
  // Check if there's another batch of receipts to collect every 10s
  timer(10_000).pipe(async () => {
  - while (this.receiptsToCollect.length > 0) {
  - // Check whether the next receipts batch timeout has expired
  - let batch = this.receiptsToCollect.peek()
  - if (batch && batch.timeout <= Date.now()) {
  + while (hasReceiptsReadyForCollecting()) {
  // Remove the batch from the processing queue
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  - batch = this.receiptsToCollect.pop()!
  + const batch = this.receiptsToCollect.pop()!
  // If the array is empty we cannot know what allocation this group
  // belongs to. Should this assertion ever fail, then there is a
  @@ -176,7 +178,6 @@ export class AllocationReceiptCollector implements ReceiptCollector {
  // Collect the receipts now
  await this.obtainReceiptsVoucher(batch.receipts)
  }
  - }
  })
  }
  