diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 802a80b2..473244c0 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -391,7 +391,7 @@ func errorToPaymentFailure(err error) channeldb.FailureReason { errNoTlvPayload, errNoPaymentAddr, errNoPathFound, - errPrebuiltRouteTried: + errEmptyPaySession: return channeldb.FailureReasonNoRoute diff --git a/routing/payment_session.go b/routing/payment_session.go index a5c04266..f8c29755 100644 --- a/routing/payment_session.go +++ b/routing/payment_session.go @@ -13,9 +13,9 @@ import ( const BlockPadding uint16 = 3 var ( - // errPrebuiltRouteTried is returned when the single pre-built route - // failed and there is nothing more we can do. - errPrebuiltRouteTried = errors.New("pre-built route already tried") + // errEmptyPaySession is returned when the empty payment session is + // queried for a route. + errEmptyPaySession = errors.New("empty payment session") ) // PaymentSession is used during SendPayment attempts to provide routes to @@ -50,8 +50,7 @@ type paymentSession struct { payment *LightningPayment - preBuiltRoute *route.Route - preBuiltRouteTried bool + empty bool pathFinder pathFinder } @@ -68,18 +67,8 @@ type paymentSession struct { func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi, activeShards, height uint32) (*route.Route, error) { - switch { - - // If we have a pre-built route, use that directly. - case p.preBuiltRoute != nil && !p.preBuiltRouteTried: - p.preBuiltRouteTried = true - - return p.preBuiltRoute, nil - - // If the pre-built route has been tried already, the payment session is - // over. - case p.preBuiltRoute != nil: - return nil, errPrebuiltRouteTried + if p.empty { + return nil, errEmptyPaySession } // Add BlockPadding to the finalCltvDelta so that the receiving node diff --git a/routing/payment_session_source.go b/routing/payment_session_source.go index f3fd968e..3d6cfedf 100644 --- a/routing/payment_session_source.go +++ b/routing/payment_session_source.go @@ -75,23 +75,13 @@ func (m *SessionSource) NewPaymentSession(p *LightningPayment) ( }, nil } -// NewPaymentSessionForRoute creates a new paymentSession instance that is just -// used for failure reporting to missioncontrol. -func (m *SessionSource) NewPaymentSessionForRoute(preBuiltRoute *route.Route) PaymentSession { - return &paymentSession{ - sessionSource: m, - preBuiltRoute: preBuiltRoute, - } -} - // NewPaymentSessionEmpty creates a new paymentSession instance that is empty, // and will be exhausted immediately. Used for failure reporting to // missioncontrol for resumed payment we don't want to make more attempts for. func (m *SessionSource) NewPaymentSessionEmpty() PaymentSession { return &paymentSession{ - sessionSource: m, - preBuiltRoute: &route.Route{}, - preBuiltRouteTried: true, + sessionSource: m, + empty: true, } } diff --git a/routing/router.go b/routing/router.go index 7f860c89..a5cf8488 100644 --- a/routing/router.go +++ b/routing/router.go @@ -161,11 +161,6 @@ type PaymentSessionSource interface { // finding a path to the payment's destination. NewPaymentSession(p *LightningPayment) (PaymentSession, error) - // NewPaymentSessionForRoute creates a new paymentSession instance that - // is just used for failure reporting to missioncontrol, and will only - // attempt the given route. - NewPaymentSessionForRoute(preBuiltRoute *route.Route) PaymentSession - // NewPaymentSessionEmpty creates a new paymentSession instance that is // empty, and will be exhausted immediately. Used for failure reporting // to missioncontrol for resumed payment we don't want to make more