Skip to content

Commit a0f8724

Browse files
committed
sweepbatcher: remove all completed batches
Previously, if a completed batch was visited after a batch to which the sweep was added, it was not deleted because the function returned early. This has been separated into two loops: the first one removes completed batches, and the second one adds the sweep to a batch.
1 parent a64f461 commit a0f8724

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sweepbatcher/sweep_batcher.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,17 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep,
590590

591591
sweep.notifier = notifier
592592

593-
// Check if the sweep is already in a batch. If that is the case, we
594-
// provide the sweep to that batch and return.
593+
// This is a check to see if a batch is completed. In that case we just
594+
// lazily delete it.
595595
for _, batch := range b.batches {
596-
// This is a check to see if a batch is completed. In that case
597-
// we just lazily delete it and continue our scan.
598596
if batch.isComplete() {
599597
delete(b.batches, batch.id)
600-
continue
601598
}
599+
}
602600

601+
// Check if the sweep is already in a batch. If that is the case, we
602+
// provide the sweep to that batch and return.
603+
for _, batch := range b.batches {
603604
if batch.sweepExists(sweep.swapHash) {
604605
accepted, err := batch.addSweep(ctx, sweep)
605606
if err != nil && !errors.Is(err, ErrBatchShuttingDown) {

0 commit comments

Comments
 (0)