Skip to content

Commit

Permalink
invoices: if there are no invoices make gc noop
Browse files Browse the repository at this point in the history
  • Loading branch information
djkazic committed Apr 30, 2024
1 parent e8a1d48 commit 1542424
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 1542424

Please sign in to comment.