mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
routing: remove errNoRoute and lastError
Now that SendToRoute is no longer using the payment lifecycle, we remove the error structs and vars used to cache the last encountered error. For SendToRoute this will now be returned directly after a shard has failed. For SendPayment this means that the last error encountered durinng pathfinding no longer will be returned. All errors encounterd can instead be inspected from the HTLC list.
This commit is contained in:
@ -13,20 +13,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
|
||||
// errNoRoute is returned when all routes from the payment session have been
|
||||
// attempted.
|
||||
type errNoRoute struct {
|
||||
// lastError is the error encountered during the last payment attempt,
|
||||
// if at least one attempt has been made.
|
||||
lastError error
|
||||
}
|
||||
|
||||
// Error returns a string representation of the error.
|
||||
func (e errNoRoute) Error() string {
|
||||
return fmt.Sprintf("unable to route payment to destination: %v",
|
||||
e.lastError)
|
||||
}
|
||||
|
||||
// paymentLifecycle holds all information about the current state of a payment
|
||||
// needed to resume if from any point.
|
||||
type paymentLifecycle struct {
|
||||
@ -146,14 +132,6 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
|
||||
return [32]byte{}, nil, saveErr
|
||||
}
|
||||
|
||||
// If there was an error already recorded for this
|
||||
// payment, we'll return that.
|
||||
if shardHandler.lastError != nil {
|
||||
return [32]byte{}, nil, errNoRoute{
|
||||
lastError: shardHandler.lastError,
|
||||
}
|
||||
}
|
||||
|
||||
// Terminal state, return.
|
||||
return [32]byte{}, nil, err
|
||||
}
|
||||
@ -232,8 +210,6 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
|
||||
type shardHandler struct {
|
||||
paymentHash lntypes.Hash
|
||||
router *ChannelRouter
|
||||
|
||||
lastError error
|
||||
}
|
||||
|
||||
// launchOutcome is a type returned from launchShard that indicates whether the
|
||||
@ -542,9 +518,6 @@ func (p *shardHandler) handleSendError(attempt *channeldb.HTLCAttemptInfo,
|
||||
attempt.AttemptID, &attempt.Route, sendErr,
|
||||
)
|
||||
if reason == nil {
|
||||
// Save the forwarding error so it can be returned if
|
||||
// this turns out to be the last attempt.
|
||||
p.lastError = sendErr
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user