mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-27 18:22:24 +01:00
routing/refactor: add failNode helper to final outcome processing
Note: this refactor updates the inequality used from >= 2 to > 1 to align with the rest of this file so that we express this concept consistently throughout the code.
This commit is contained in:
parent
b82478a7e7
commit
7ce3a152a1
@ -201,6 +201,17 @@ func (i *interpretedResult) processPaymentOutcomeFinal(
|
||||
|
||||
n := len(route.Hops)
|
||||
|
||||
failNode := func() {
|
||||
i.failNode(route, n)
|
||||
|
||||
// Other channels in the route forwarded correctly.
|
||||
if n > 1 {
|
||||
i.successPairRange(route, 0, n-2)
|
||||
}
|
||||
|
||||
i.finalFailureReason = &reasonError
|
||||
}
|
||||
|
||||
// If a failure from the final node is received, we will fail the
|
||||
// payment in almost all cases. Only when the penultimate node sends an
|
||||
// incorrect htlc, we want to retry via another route. Invalid onion
|
||||
@ -256,18 +267,11 @@ func (i *interpretedResult) processPaymentOutcomeFinal(
|
||||
// destination correctly. Continue the payment process.
|
||||
i.successPairRange(route, 0, n-1)
|
||||
|
||||
// All other errors are considered terminal if coming from the
|
||||
// final hop. They indicate that something is wrong at the
|
||||
// recipient, so we do apply a penalty.
|
||||
default:
|
||||
// All other errors are considered terminal if coming from the
|
||||
// final hop. They indicate that something is wrong at the
|
||||
// recipient, so we do apply a penalty.
|
||||
i.failNode(route, n)
|
||||
|
||||
// Other channels in the route forwarded correctly.
|
||||
if n >= 2 {
|
||||
i.successPairRange(route, 0, n-2)
|
||||
}
|
||||
|
||||
i.finalFailureReason = &reasonError
|
||||
failNode()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user