invoices: ensure ntfns are sent in the same order

SettleHodlInvoice and CancelInvoice both notifyClients after
notifyHodlSubscribers. This commit changes UpdateInvoice to follow the
same pattern so that we are consistent.
This commit is contained in:
Conner Fromknecht 2020-04-23 23:24:30 -07:00
parent f5581eb04a
commit 47cf144170
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

View File

@ -829,10 +829,6 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
return nil, err
}
if updateSubscribers {
i.notifyClients(ctx.hash, invoice, invoice.State)
}
switch res := resolution.(type) {
case *HtlcFailResolution:
// Inspect latest htlc state on the invoice. If it is found,
@ -851,8 +847,6 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
"outcome: %v, at accept height: %v",
res.Outcome, res.AcceptHeight))
return res, nil
// If the htlc was settled, we will settle any previously accepted
// htlcs and notify our peer to settle them.
case *HtlcSettleResolution:
@ -883,8 +877,6 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
i.notifyHodlSubscribers(htlcSettleResolution)
}
return resolution, nil
// If we accepted the htlc, subscribe to the hodl invoice and return
// an accept resolution with the htlc's accept time on it.
case *htlcAcceptResolution:
@ -915,11 +907,19 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
}
i.hodlSubscribe(hodlChan, ctx.circuitKey)
return res, nil
default:
panic("unknown action")
}
// Now that the links have been notified of any state changes to their
// HTLCs, we'll go ahead and notify any clients wiaiting on the invoice
// state changes.
if updateSubscribers {
i.notifyClients(ctx.hash, invoice, invoice.State)
}
return resolution, nil
}
// SettleHodlInvoice sets the preimage of a hodl invoice.