invoices: re-format overreaching code lines

This commit is contained in:
Andras Banki-Horvath 2020-07-17 14:24:54 +02:00
parent f144dea3da
commit ba3c65bfd6
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8
2 changed files with 20 additions and 12 deletions

View File

@ -48,8 +48,8 @@ type InvoiceExpiryWatcher struct {
// invoice to expire.
expiryQueue queue.PriorityQueue
// newInvoices channel is used to wake up the main loop when a new invoices
// is added.
// newInvoices channel is used to wake up the main loop when a new
// invoices is added.
newInvoices chan []*invoiceExpiry
wg sync.WaitGroup
@ -109,7 +109,8 @@ func (ew *InvoiceExpiryWatcher) prepareInvoice(
paymentHash lntypes.Hash, invoice *channeldb.Invoice) *invoiceExpiry {
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
}
@ -133,10 +134,13 @@ func (ew *InvoiceExpiryWatcher) AddInvoices(
invoicesWithExpiry := make([]*invoiceExpiry, 0, len(invoices))
for _, invoiceWithPaymentHash := range invoices {
newInvoiceExpiry := ew.prepareInvoice(
invoiceWithPaymentHash.PaymentHash, &invoiceWithPaymentHash.Invoice,
invoiceWithPaymentHash.PaymentHash,
&invoiceWithPaymentHash.Invoice,
)
if newInvoiceExpiry != nil {
invoicesWithExpiry = append(invoicesWithExpiry, newInvoiceExpiry)
invoicesWithExpiry = append(
invoicesWithExpiry, newInvoiceExpiry,
)
}
}
@ -160,8 +164,8 @@ func (ew *InvoiceExpiryWatcher) AddInvoice(
newInvoiceExpiry := ew.prepareInvoice(paymentHash, invoice)
if newInvoiceExpiry != nil {
log.Debugf("Adding invoice '%v' to expiry watcher, expiration: %v",
paymentHash, newInvoiceExpiry.Expiry)
log.Debugf("Adding invoice '%v' to expiry watcher,"+
"expiration: %v", paymentHash, newInvoiceExpiry.Expiry)
select {
case ew.newInvoices <- []*invoiceExpiry{newInvoiceExpiry}:
@ -202,7 +206,8 @@ func (ew *InvoiceExpiryWatcher) cancelNextExpiredInvoice() {
if err != nil && err != channeldb.ErrInvoiceAlreadySettled &&
err != channeldb.ErrInvoiceAlreadyCanceled {
log.Errorf("Unable to cancel invoice: %v", top.PaymentHash)
log.Errorf("Unable to cancel invoice: %v",
top.PaymentHash)
}
ew.expiryQueue.Pop()
@ -236,8 +241,8 @@ func (ew *InvoiceExpiryWatcher) mainLoop() {
continue
case invoicesWithExpiry := <-ew.newInvoices:
for _, invoiceWithExpiry := range invoicesWithExpiry {
ew.expiryQueue.Push(invoiceWithExpiry)
for _, invoice := range invoicesWithExpiry {
ew.expiryQueue.Push(invoice)
}
case <-ew.quit:

View File

@ -37,7 +37,9 @@ func newInvoiceExpiryWatcherTest(t *testing.T, now time.Time,
err := test.watcher.Start(func(paymentHash lntypes.Hash,
force bool) error {
test.canceledInvoices = append(test.canceledInvoices, paymentHash)
test.canceledInvoices = append(
test.canceledInvoices, paymentHash,
)
test.wg.Done()
return nil
})
@ -70,7 +72,8 @@ func (t *invoiceExpiryWatcherTest) checkExpectations() {
// that expired.
if len(t.canceledInvoices) != len(t.testData.expiredInvoices) {
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 {