From ba3c65bfd6c05cf0733aae7f96b75dc93bcdb2fe Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Fri, 17 Jul 2020 14:24:54 +0200 Subject: [PATCH] invoices: re-format overreaching code lines --- invoices/invoice_expiry_watcher.go | 25 +++++++++++++++---------- invoices/invoice_expiry_watcher_test.go | 7 +++++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/invoices/invoice_expiry_watcher.go b/invoices/invoice_expiry_watcher.go index f0db08d11..9df6ca745 100644 --- a/invoices/invoice_expiry_watcher.go +++ b/invoices/invoice_expiry_watcher.go @@ -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: diff --git a/invoices/invoice_expiry_watcher_test.go b/invoices/invoice_expiry_watcher_test.go index 2aa0f87ba..58d6e2d8d 100644 --- a/invoices/invoice_expiry_watcher_test.go +++ b/invoices/invoice_expiry_watcher_test.go @@ -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 {