invoices: re-format overreaching code lines
This commit is contained in:
parent
f144dea3da
commit
ba3c65bfd6
@ -48,8 +48,8 @@ type InvoiceExpiryWatcher struct {
|
|||||||
// invoice to expire.
|
// invoice to expire.
|
||||||
expiryQueue queue.PriorityQueue
|
expiryQueue queue.PriorityQueue
|
||||||
|
|
||||||
// newInvoices channel is used to wake up the main loop when a new invoices
|
// newInvoices channel is used to wake up the main loop when a new
|
||||||
// is added.
|
// invoices is added.
|
||||||
newInvoices chan []*invoiceExpiry
|
newInvoices chan []*invoiceExpiry
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
@ -109,7 +109,8 @@ func (ew *InvoiceExpiryWatcher) prepareInvoice(
|
|||||||
paymentHash lntypes.Hash, invoice *channeldb.Invoice) *invoiceExpiry {
|
paymentHash lntypes.Hash, invoice *channeldb.Invoice) *invoiceExpiry {
|
||||||
|
|
||||||
if invoice.State != channeldb.ContractOpen {
|
if invoice.State != channeldb.ContractOpen {
|
||||||
log.Debugf("Invoice not added to expiry watcher: %v", paymentHash)
|
log.Debugf("Invoice not added to expiry watcher: %v",
|
||||||
|
paymentHash)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,10 +134,13 @@ func (ew *InvoiceExpiryWatcher) AddInvoices(
|
|||||||
invoicesWithExpiry := make([]*invoiceExpiry, 0, len(invoices))
|
invoicesWithExpiry := make([]*invoiceExpiry, 0, len(invoices))
|
||||||
for _, invoiceWithPaymentHash := range invoices {
|
for _, invoiceWithPaymentHash := range invoices {
|
||||||
newInvoiceExpiry := ew.prepareInvoice(
|
newInvoiceExpiry := ew.prepareInvoice(
|
||||||
invoiceWithPaymentHash.PaymentHash, &invoiceWithPaymentHash.Invoice,
|
invoiceWithPaymentHash.PaymentHash,
|
||||||
|
&invoiceWithPaymentHash.Invoice,
|
||||||
)
|
)
|
||||||
if newInvoiceExpiry != nil {
|
if newInvoiceExpiry != nil {
|
||||||
invoicesWithExpiry = append(invoicesWithExpiry, newInvoiceExpiry)
|
invoicesWithExpiry = append(
|
||||||
|
invoicesWithExpiry, newInvoiceExpiry,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +164,8 @@ func (ew *InvoiceExpiryWatcher) AddInvoice(
|
|||||||
|
|
||||||
newInvoiceExpiry := ew.prepareInvoice(paymentHash, invoice)
|
newInvoiceExpiry := ew.prepareInvoice(paymentHash, invoice)
|
||||||
if newInvoiceExpiry != nil {
|
if newInvoiceExpiry != nil {
|
||||||
log.Debugf("Adding invoice '%v' to expiry watcher, expiration: %v",
|
log.Debugf("Adding invoice '%v' to expiry watcher,"+
|
||||||
paymentHash, newInvoiceExpiry.Expiry)
|
"expiration: %v", paymentHash, newInvoiceExpiry.Expiry)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case ew.newInvoices <- []*invoiceExpiry{newInvoiceExpiry}:
|
case ew.newInvoices <- []*invoiceExpiry{newInvoiceExpiry}:
|
||||||
@ -202,7 +206,8 @@ func (ew *InvoiceExpiryWatcher) cancelNextExpiredInvoice() {
|
|||||||
if err != nil && err != channeldb.ErrInvoiceAlreadySettled &&
|
if err != nil && err != channeldb.ErrInvoiceAlreadySettled &&
|
||||||
err != channeldb.ErrInvoiceAlreadyCanceled {
|
err != channeldb.ErrInvoiceAlreadyCanceled {
|
||||||
|
|
||||||
log.Errorf("Unable to cancel invoice: %v", top.PaymentHash)
|
log.Errorf("Unable to cancel invoice: %v",
|
||||||
|
top.PaymentHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
ew.expiryQueue.Pop()
|
ew.expiryQueue.Pop()
|
||||||
@ -236,8 +241,8 @@ func (ew *InvoiceExpiryWatcher) mainLoop() {
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
case invoicesWithExpiry := <-ew.newInvoices:
|
case invoicesWithExpiry := <-ew.newInvoices:
|
||||||
for _, invoiceWithExpiry := range invoicesWithExpiry {
|
for _, invoice := range invoicesWithExpiry {
|
||||||
ew.expiryQueue.Push(invoiceWithExpiry)
|
ew.expiryQueue.Push(invoice)
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-ew.quit:
|
case <-ew.quit:
|
||||||
|
@ -37,7 +37,9 @@ func newInvoiceExpiryWatcherTest(t *testing.T, now time.Time,
|
|||||||
err := test.watcher.Start(func(paymentHash lntypes.Hash,
|
err := test.watcher.Start(func(paymentHash lntypes.Hash,
|
||||||
force bool) error {
|
force bool) error {
|
||||||
|
|
||||||
test.canceledInvoices = append(test.canceledInvoices, paymentHash)
|
test.canceledInvoices = append(
|
||||||
|
test.canceledInvoices, paymentHash,
|
||||||
|
)
|
||||||
test.wg.Done()
|
test.wg.Done()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -70,7 +72,8 @@ func (t *invoiceExpiryWatcherTest) checkExpectations() {
|
|||||||
// that expired.
|
// that expired.
|
||||||
if len(t.canceledInvoices) != len(t.testData.expiredInvoices) {
|
if len(t.canceledInvoices) != len(t.testData.expiredInvoices) {
|
||||||
t.t.Fatalf("expected %v cancellations, got %v",
|
t.t.Fatalf("expected %v cancellations, got %v",
|
||||||
len(t.testData.expiredInvoices), len(t.canceledInvoices))
|
len(t.testData.expiredInvoices),
|
||||||
|
len(t.canceledInvoices))
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range t.canceledInvoices {
|
for i := range t.canceledInvoices {
|
||||||
|
Loading…
Reference in New Issue
Block a user