From 23daad2f6116245cb871b9ee9f0d5d4d4417625a Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 24 Jun 2022 16:21:26 +0200 Subject: [PATCH] add isSetComplete helper --- invoiceregistry.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/invoiceregistry.go b/invoiceregistry.go index a0ff76b..1f5ced6 100644 --- a/invoiceregistry.go +++ b/invoiceregistry.go @@ -84,6 +84,10 @@ func (i *invoiceState) totalSetAmt() int { return total } +func (i *invoiceState) isSetComplete() bool { + return i.totalSetAmt() == int(i.invoice.Value) +} + type invoiceRequest struct { hash lntypes.Hash errChan chan error @@ -568,7 +572,7 @@ func (i *InvoiceRegistry) failInvoice(ctx context.Context, } // Don't expire invoices that are already accepted. - setComplete := state.totalSetAmt() == int(state.invoice.Value) + setComplete := state.isSetComplete() if reason == persistence.CancelledReasonExpired && setComplete { return nil } @@ -667,8 +671,7 @@ func (i *InvoiceRegistry) cancelSingleHtlc(hash lntypes.Hash, } // Do nothing if the set is already complete. - setComplete := invoice.totalSetAmt() == int(invoice.invoice.Value) - if setComplete { + if invoice.isSetComplete() { return nil }