mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
sweepbatcher: cancel spendCtx after processing
Function monitorSpendAndNotify used to cancel the context passed to RegisterSpendNtfn right after starting the goroutine processing results. Spend notifications were missed. Now the context is canceled when the goroutine finishes.
This commit is contained in:
parent
2f05934dbb
commit
01664ad635
1 changed files with 5 additions and 1 deletions
|
|
@ -1128,11 +1128,12 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|||
parentBatchID int32, notifier *SpendNotifier) error {
|
||||
|
||||
spendCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
// Then we get the total amount that was swept by the batch.
|
||||
totalSwept, err := b.store.TotalSweptAmount(ctx, parentBatchID)
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -1141,11 +1142,14 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|||
sweep.initiationHeight,
|
||||
)
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
b.wg.Add(1)
|
||||
go func() {
|
||||
defer cancel()
|
||||
defer b.wg.Done()
|
||||
infof("Batcher monitoring spend for swap %x",
|
||||
sweep.swapHash[:6])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue