Skip to content

Commit

Permalink
add isSetComplete helper
Browse files Browse the repository at this point in the history
  • Loading branch information
joostjager committed Jun 29, 2022
1 parent e04e478 commit 23daad2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions invoiceregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 23daad2

Please sign in to comment.