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:
Johan T. Halseth
2020-04-01 00:13:22 +02:00
parent 77df8e3a43
commit c2301c14b2
6 changed files with 54 additions and 61 deletions

View File

@ -44,16 +44,6 @@ func TestRequestRoute(t *testing.T) {
},
}
session := &paymentSession{
getBandwidthHints: func() (map[uint64]lnwire.MilliSatoshi,
error) {
return nil, nil
},
sessionSource: sessionSource,
pathFinder: findPath,
}
cltvLimit := uint32(30)
finalCltvDelta := uint16(8)
@ -62,7 +52,18 @@ func TestRequestRoute(t *testing.T) {
FinalCLTVDelta: finalCltvDelta,
}
route, err := session.RequestRoute(payment, height, finalCltvDelta)
session := &paymentSession{
getBandwidthHints: func() (map[uint64]lnwire.MilliSatoshi,
error) {
return nil, nil
},
sessionSource: sessionSource,
payment: payment,
pathFinder: findPath,
}
route, err := session.RequestRoute(height)
if err != nil {
t.Fatal(err)
}