Skip to content

Commit 0657bc6

Browse files
committed
sweepbatcher: store batch status before monitoring
If monitorConfirmations fails, we still want to persist the state to DB.
1 parent 1848e70 commit 0657bc6

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
@@ -2079,16 +2079,20 @@ func (b *batch) handleSpend(ctx context.Context, spendTx *wire.MsgTx) error {
20792079
b.Infof("spent, confirmed sweeps: %v, purged sweeps: %v, "+
20802080
"purged swaps: %v", confirmedSweeps, purgedSweeps, purgedSwaps)
20812081

2082-
err = b.monitorConfirmations(ctx)
2083-
if err != nil {
2084-
return err
2085-
}
2086-
20872082
// We are no longer able to accept new sweeps, so we mark the batch as
20882083
// closed and persist on storage.
20892084
b.state = Closed
20902085

2091-
return b.persist(ctx)
2086+
if err := b.persist(ctx); err != nil {
2087+
return fmt.Errorf("saving batch failed: %w", err)
2088+
}
2089+
2090+
err = b.monitorConfirmations(ctx)
2091+
if err != nil {
2092+
return fmt.Errorf("monitorConfirmations failed: %w", err)
2093+
}
2094+
2095+
return nil
20922096
}
20932097

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

0 commit comments

Comments
 (0)