Skip to content

Commit 05c208f

Browse files
committed
sweepbatcher: store batch status before monitoring
If monitorConfirmations fails, we still want to persist the state to DB.
1 parent fbfc4f5 commit 05c208f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sweepbatcher/sweep_batch.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,16 +2099,20 @@ func (b *batch) handleSpend(ctx context.Context, spendTx *wire.MsgTx) error {
20992099
"purged swaps: %v, purged groups: %v", confirmedSweeps,
21002100
purgedSweeps, purgedSwaps, len(purgeList))
21012101

2102-
err = b.monitorConfirmations(ctx)
2103-
if err != nil {
2104-
return err
2105-
}
2106-
21072102
// We are no longer able to accept new sweeps, so we mark the batch as
21082103
// closed and persist on storage.
21092104
b.state = Closed
21102105

2111-
return b.persist(ctx)
2106+
if err := b.persist(ctx); err != nil {
2107+
return fmt.Errorf("saving batch failed: %w", err)
2108+
}
2109+
2110+
err = b.monitorConfirmations(ctx)
2111+
if err != nil {
2112+
return fmt.Errorf("monitorConfirmations failed: %w", err)
2113+
}
2114+
2115+
return nil
21122116
}
21132117

21142118
// handleConf handles a confirmation notification. This is the final step of the

0 commit comments

Comments
 (0)