mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
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.
This commit is contained in:
parent
a64f4610ab
commit
a0f87241da
1 changed files with 8 additions and 7 deletions
|
|
@ -590,16 +590,17 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep,
|
|||
|
||||
sweep.notifier = notifier
|
||||
|
||||
// This is a check to see if a batch is completed. In that case we just
|
||||
// lazily delete it.
|
||||
for _, batch := range b.batches {
|
||||
if batch.isComplete() {
|
||||
delete(b.batches, batch.id)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the sweep is already in a batch. If that is the case, we
|
||||
// provide the sweep to that batch and return.
|
||||
for _, batch := range b.batches {
|
||||
// This is a check to see if a batch is completed. In that case
|
||||
// we just lazily delete it and continue our scan.
|
||||
if batch.isComplete() {
|
||||
delete(b.batches, batch.id)
|
||||
continue
|
||||
}
|
||||
|
||||
if batch.sweepExists(sweep.swapHash) {
|
||||
accepted, err := batch.addSweep(ctx, sweep)
|
||||
if err != nil && !errors.Is(err, ErrBatchShuttingDown) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue