Skip to content

Commit 15aeb11

Browse files
stariushieblmi
authored andcommitted
sweepbatcher: store batch status before monitoring
If monitorConfirmations fails, we still want to persist the state to DB.
1 parent a8456b8 commit 15aeb11

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

sweepbatcher/sweep_batch.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,16 +2099,19 @@ 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+
if err = b.monitorConfirmations(ctx); err != nil {
2111+
return fmt.Errorf("monitorConfirmations failed: %w", err)
2112+
}
2113+
2114+
return nil
21122115
}
21132116

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

0 commit comments

Comments
 (0)