Merge pull request #4275 from cfromknecht/invoices-ntfn-order

invoices: ensure ntfns are sent in the same order
This commit is contained in:
Conner Fromknecht
2020-06-22 12:15:07 -07:00
committed by GitHub

View File

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