Skip to content

Commit 2fdf4c1

Browse files
committed
sweepbatcher: store batch status before monitoring
If monitorConfirmations fails, we still want to persist the state to DB.
1 parent 4b44967 commit 2fdf4c1

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
@@ -1890,16 +1890,20 @@ func (b *batch) handleSpend(ctx context.Context, spendTx *wire.MsgTx) error {
18901890
b.Infof("spent, total sweeps: %v, purged sweeps: %v",
18911891
len(notifyList), len(purgeList))
18921892

1893-
err := b.monitorConfirmations(ctx)
1894-
if err != nil {
1895-
return err
1896-
}
1897-
18981893
// We are no longer able to accept new sweeps, so we mark the batch as
18991894
// closed and persist on storage.
19001895
b.state = Closed
19011896

1902-
return b.persist(ctx)
1897+
if err := b.persist(ctx); err != nil {
1898+
return fmt.Errorf("saving batch failed: %w", err)
1899+
}
1900+
1901+
err := b.monitorConfirmations(ctx)
1902+
if err != nil {
1903+
return fmt.Errorf("monitorConfirmations failed: %w", err)
1904+
}
1905+
1906+
return nil
19031907
}
19041908

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

0 commit comments

Comments
 (0)