routing/payment_session: remove prebuilt payment session

Since we no longer use payment sessions for send to route, we remove the
prebuilt one.
This commit is contained in:
Johan T. Halseth 2020-04-01 00:13:25 +02:00
parent 4509c4f3a9
commit 49efbefb43
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
4 changed files with 9 additions and 35 deletions

@ -391,7 +391,7 @@ func errorToPaymentFailure(err error) channeldb.FailureReason {
errNoTlvPayload,
errNoPaymentAddr,
errNoPathFound,
errPrebuiltRouteTried:
errEmptyPaySession:
return channeldb.FailureReasonNoRoute

@ -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

@ -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,
empty: true,
}
}

@ -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