routing: handle switch error when sendAttempt fails

This commit starts handling switch error inside `sendAttempt` when an
error is returned from sending the HTLC. To make sure the updated
`HTLCAttempt` is always returned to the callsite, `handleSwitchErr` now
also returns a `attemptResult`.
This commit is contained in:
yyforyongyu
2023-03-07 18:39:26 +08:00
parent 568b977a1f
commit 49bafc0207
2 changed files with 25 additions and 18 deletions

View File

@@ -2558,7 +2558,7 @@ func (r *ChannelRouter) sendToRoute(htlcHash lntypes.Hash, rt *route.Route,
// the error to check if it maps into a terminal error code, if not use
// a generic NO_ROUTE error.
var failureReason *channeldb.FailureReason
err = p.handleSwitchErr(attempt, shardError)
_, err = p.handleSwitchErr(attempt, shardError)
switch {
// If a non-terminal error is returned and `skipTempErr` is false, then