Skip to content

Commit

Permalink
Merge pull request #8712 from djkazic/invoice-gc-noop
Browse files Browse the repository at this point in the history
invoices: if there are no invoices make gc noop
  • Loading branch information
guggero authored May 1, 2024
2 parents e8a1d48 + 1542424 commit fb632bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions channeldb/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -2139,14 +2139,14 @@ func (d *DB) DeleteCanceledInvoices(_ context.Context) error {
invoiceIndexBucket,
)
if invoiceIndex == nil {
return invpkg.ErrNoInvoicesCreated
return nil
}

invoiceAddIndex := invoices.NestedReadWriteBucket(
addIndexBucket,
)
if invoiceAddIndex == nil {
return invpkg.ErrNoInvoicesCreated
return nil
}

payAddrIndex := tx.ReadWriteBucket(payAddrIndexBucket)
Expand Down
5 changes: 4 additions & 1 deletion invoices/invoices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2681,8 +2681,11 @@ func testDeleteCanceledInvoices(t *testing.T,
}, nil
}

// Add some invoices to the test db.
// Test deletion of canceled invoices when there are none.
ctxb := context.Background()
require.NoError(t, db.DeleteCanceledInvoices(ctxb))

// Add some invoices to the test db.
var invoices []invpkg.Invoice
for i := 0; i < 10; i++ {
invoice, err := randInvoice(lnwire.MilliSatoshi(i + 1))
Expand Down

0 comments on commit fb632bb

Please sign in to comment.