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:
parent
0ea763d83c
commit
a0d7877d9a
@ -242,6 +242,8 @@ type Config struct {
|
|||||||
|
|
||||||
KeysendHoldTime time.Duration `long:"keysend-hold-time" description:"If non-zero, keysend payments are accepted but not immediately settled. If the payment isn't settled manually after the specified time, it is canceled automatically. [experimental]"`
|
KeysendHoldTime time.Duration `long:"keysend-hold-time" description:"If non-zero, keysend payments are accepted but not immediately settled. If the payment isn't settled manually after the specified time, it is canceled automatically. [experimental]"`
|
||||||
|
|
||||||
|
GcCanceledInvoicesOnStartup bool `long:"gc-canceled-invoices-on-startup" description:"If true, we'll attempt to garbage collect canceled invoices upon start."`
|
||||||
|
|
||||||
Routing *routing.Conf `group:"routing" namespace:"routing"`
|
Routing *routing.Conf `group:"routing" namespace:"routing"`
|
||||||
|
|
||||||
Workers *lncfg.Workers `group:"workers" namespace:"workers"`
|
Workers *lncfg.Workers `group:"workers" namespace:"workers"`
|
||||||
|
@ -57,6 +57,10 @@ type RegistryConfig struct {
|
|||||||
// send payments.
|
// send payments.
|
||||||
AcceptKeySend bool
|
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
|
// KeysendHoldTime indicates for how long we want to accept and hold
|
||||||
// spontaneous keysend payments.
|
// spontaneous keysend payments.
|
||||||
KeysendHoldTime time.Duration
|
KeysendHoldTime time.Duration
|
||||||
@ -171,7 +175,9 @@ func (i *InvoiceRegistry) scanInvoicesOnStart() error {
|
|||||||
|
|
||||||
if invoice.IsPending() {
|
if invoice.IsPending() {
|
||||||
pending[paymentHash] = invoice
|
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
|
// Consider invoice for removal if it is already
|
||||||
// canceled. Invoices that are expired but not yet
|
// canceled. Invoices that are expired but not yet
|
||||||
// canceled, will be queued up for cancellation after
|
// canceled, will be queued up for cancellation after
|
||||||
|
@ -1093,6 +1093,7 @@ func TestOldInvoiceRemovalOnStart(t *testing.T) {
|
|||||||
cfg := RegistryConfig{
|
cfg := RegistryConfig{
|
||||||
FinalCltvRejectDelta: testFinalCltvRejectDelta,
|
FinalCltvRejectDelta: testFinalCltvRejectDelta,
|
||||||
Clock: testClock,
|
Clock: testClock,
|
||||||
|
GcCanceledInvoicesOnStartup: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
expiryWatcher := NewInvoiceExpiryWatcher(cfg.Clock)
|
expiryWatcher := NewInvoiceExpiryWatcher(cfg.Clock)
|
||||||
|
@ -400,6 +400,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
|
|||||||
HtlcHoldDuration: invoices.DefaultHtlcHoldDuration,
|
HtlcHoldDuration: invoices.DefaultHtlcHoldDuration,
|
||||||
Clock: clock.NewDefaultClock(),
|
Clock: clock.NewDefaultClock(),
|
||||||
AcceptKeySend: cfg.AcceptKeySend,
|
AcceptKeySend: cfg.AcceptKeySend,
|
||||||
|
GcCanceledInvoicesOnStartup: cfg.GcCanceledInvoicesOnStartup,
|
||||||
KeysendHoldTime: cfg.KeysendHoldTime,
|
KeysendHoldTime: cfg.KeysendHoldTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user