routing: add FetchPayment method to ControlTower
This method is used to fetch a payment and all HTLC attempt that have been made for that payment. It will both be used to resume inflight attempts, and to fetch the final outcome of previous attempts. We also update the the mock control tower to mimic the real control tower, by letting it track multiple HTLC attempts for a given payment hash, laying the groundwork for later enabling it for MPP.
This commit is contained in:
2 files changed
+169
-25
No files matched your search
@@ -34,6 +34,10 @@ type ControlTower interface {
|
||||
// FailAttempt marks the given payment attempt failed.
|
||||
FailAttempt(lntypes.Hash, uint64, *channeldb.HTLCFailInfo) error
|
||||
|
||||
// FetchPayment fetches the payment corresponding to the given payment
|
||||
// hash.
|
||||
FetchPayment(paymentHash lntypes.Hash) (*channeldb.MPPayment, error)
|
||||
|
||||
// Fail transitions a payment into the Failed state, and records the
|
||||
// ultimate reason the payment failed. Note that this should only be
|
||||
// called when all active active attempts are already failed. After
|
||||
@@ -132,6 +136,13 @@ func (p *controlTower) FailAttempt(paymentHash lntypes.Hash,
|
||||
return p.db.FailAttempt(paymentHash, attemptID, failInfo)
|
||||
}
|
||||
|
||||
// FetchPayment fetches the payment corresponding to the given payment hash.
|
||||
func (p *controlTower) FetchPayment(paymentHash lntypes.Hash) (
|
||||
*channeldb.MPPayment, error) {
|
||||
|
||||
return p.db.FetchPayment(paymentHash)
|
||||
}
|
||||
|
||||
// createSuccessResult creates a success result to send to subscribers.
|
||||
func createSuccessResult(htlcs []channeldb.HTLCAttempt) *PaymentResult {
|
||||
// Extract any preimage from the list of HTLCs.
|
||||
|
||||
Reference in new issue
Block a user