routing+routerrpc: isolate payment session source from mission control

This commit is contained in:
Joost Jager committed 2019-07-13 22:38:19 +02:00
1 parent cf3dd3fb94
commit 37e2751695
12 files changed
+308 -191

No files matched your search

+24 -4
View File
@@ -171,6 +171,22 @@ type PaymentSessionSource interface {
NewPaymentSessionEmpty() PaymentSession
}
// MissionController is an interface that exposes failure reporting and
// probability estimation.
type MissionController interface {
// ReportEdgeFailure reports a channel level failure.
ReportEdgeFailure(failedEdge edge,
minPenalizeAmt lnwire.MilliSatoshi)
// ReportVertexFailure reports a node level failure.
ReportVertexFailure(v route.Vertex)
// GetEdgeProbability is expected to return the success probability of a
// payment from fromNode along edge.
GetEdgeProbability(fromNode route.Vertex, edge EdgeLocator,
amt lnwire.MilliSatoshi) float64
}
// FeeSchema is the set fee configuration for a Lightning Node on the network.
// Using the coefficients described within the schema, the required fee to
// forward outgoing payments can be derived.
@@ -234,7 +250,11 @@ type Config struct {
// Each run will then take into account this set of pruned
// vertexes/edges to reduce route failure and pass on graph information
// gained to the next execution.
MissionControl PaymentSessionSource
MissionControl MissionController
// SessionSource defines a source for the router to retrieve new payment
// sessions.
SessionSource PaymentSessionSource
// ChannelPruneExpiry is the duration used to determine if a channel
// should be pruned or not. If the delta between now and when the
@@ -544,7 +564,7 @@ func (r *ChannelRouter) Start() error {
//
// PayAttemptTime doesn't need to be set, as there is
// only a single attempt.
paySession := r.cfg.MissionControl.NewPaymentSessionEmpty()
paySession := r.cfg.SessionSource.NewPaymentSessionEmpty()
lPayment := &LightningPayment{
PaymentHash: payment.Info.PaymentHash,
@@ -1651,7 +1671,7 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
// Before starting the HTLC routing attempt, we'll create a fresh
// payment session which will report our errors back to mission
// control.
paySession, err := r.cfg.MissionControl.NewPaymentSession(
paySession, err := r.cfg.SessionSource.NewPaymentSession(
payment.RouteHints, payment.Target,
)
if err != nil {
@@ -1682,7 +1702,7 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, route *route.Route) (
lntypes.Preimage, error) {
// Create a payment session for just this route.
paySession := r.cfg.MissionControl.NewPaymentSessionForRoute(route)
paySession := r.cfg.SessionSource.NewPaymentSessionForRoute(route)
// Calculate amount paid to receiver.
amt := route.TotalAmount - route.TotalFees()