mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
multi: make canceled invoice garbage collection configurable
This commit extends the application config with a flag to control canceled invoice garbage collection upon startup.
This commit is contained in:
@@ -57,6 +57,10 @@ type RegistryConfig struct {
|
||||
// send payments.
|
||||
AcceptKeySend bool
|
||||
|
||||
// GcCanceledInvoicesOnStartup if set, we'll attempt to garbage collect
|
||||
// all canceled invoices upon start.
|
||||
GcCanceledInvoicesOnStartup bool
|
||||
|
||||
// KeysendHoldTime indicates for how long we want to accept and hold
|
||||
// spontaneous keysend payments.
|
||||
KeysendHoldTime time.Duration
|
||||
@@ -171,7 +175,9 @@ func (i *InvoiceRegistry) scanInvoicesOnStart() error {
|
||||
|
||||
if invoice.IsPending() {
|
||||
pending[paymentHash] = invoice
|
||||
} else if invoice.State == channeldb.ContractCanceled {
|
||||
} else if i.cfg.GcCanceledInvoicesOnStartup &&
|
||||
invoice.State == channeldb.ContractCanceled {
|
||||
|
||||
// Consider invoice for removal if it is already
|
||||
// canceled. Invoices that are expired but not yet
|
||||
// canceled, will be queued up for cancellation after
|
||||
|
||||
@@ -1091,8 +1091,9 @@ func TestOldInvoiceRemovalOnStart(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg := RegistryConfig{
|
||||
FinalCltvRejectDelta: testFinalCltvRejectDelta,
|
||||
Clock: testClock,
|
||||
FinalCltvRejectDelta: testFinalCltvRejectDelta,
|
||||
Clock: testClock,
|
||||
GcCanceledInvoicesOnStartup: true,
|
||||
}
|
||||
|
||||
expiryWatcher := NewInvoiceExpiryWatcher(cfg.Clock)
|
||||
|
||||
Reference in New Issue
Block a user