mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 10:09:08 +02:00
routing/payment_session: make NewPaymentSession take payment directly
This commit moves supplying of the information in the LightningPayment to the initialization of the paymentSession, away from every call to RequestRoute. Instead the paymentSession will store this information internally, as it doesn't change between payment attempts. This is done to rid the RequestRoute call of the LightingPayment argument, as for SendToRoute calls, it is not needed to supply the next route.
This commit is contained in:
@ -29,15 +29,14 @@ func (e errNoRoute) Error() string {
|
||||
// paymentLifecycle holds all information about the current state of a payment
|
||||
// needed to resume if from any point.
|
||||
type paymentLifecycle struct {
|
||||
router *ChannelRouter
|
||||
payment *LightningPayment
|
||||
paySession PaymentSession
|
||||
timeoutChan <-chan time.Time
|
||||
currentHeight int32
|
||||
finalCLTVDelta uint16
|
||||
attempt *channeldb.HTLCAttemptInfo
|
||||
circuit *sphinx.Circuit
|
||||
lastError error
|
||||
router *ChannelRouter
|
||||
payment *LightningPayment
|
||||
paySession PaymentSession
|
||||
timeoutChan <-chan time.Time
|
||||
currentHeight int32
|
||||
attempt *channeldb.HTLCAttemptInfo
|
||||
circuit *sphinx.Circuit
|
||||
lastError error
|
||||
}
|
||||
|
||||
// resumePayment resumes the paymentLifecycle from the current state.
|
||||
@ -267,9 +266,7 @@ func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID,
|
||||
}
|
||||
|
||||
// Create a new payment attempt from the given payment session.
|
||||
rt, err := p.paySession.RequestRoute(
|
||||
p.payment, uint32(p.currentHeight), p.finalCLTVDelta,
|
||||
)
|
||||
rt, err := p.paySession.RequestRoute(uint32(p.currentHeight))
|
||||
if err != nil {
|
||||
log.Warnf("Failed to find route for payment %x: %v",
|
||||
p.payment.PaymentHash, err)
|
||||
|
Reference in New Issue
Block a user