routing: abstract path finding interface
This commit is contained in:
parent
6006549ed5
commit
e3bb3d46a2
@ -226,6 +226,7 @@ func (m *missionControl) NewPaymentSession(routeHints [][]zpay32.HopHint,
|
|||||||
bandwidthHints: bandwidthHints,
|
bandwidthHints: bandwidthHints,
|
||||||
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
||||||
mc: m,
|
mc: m,
|
||||||
|
pathFinder: findPath,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +241,7 @@ func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSe
|
|||||||
preBuiltRoutes: routes,
|
preBuiltRoutes: routes,
|
||||||
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
||||||
mc: m,
|
mc: m,
|
||||||
|
pathFinder: findPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,11 @@ const (
|
|||||||
RiskFactorBillionths = 15
|
RiskFactorBillionths = 15
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// pathFinder defines the interface of a path finding algorithm.
|
||||||
|
type pathFinder = func(g *graphParams, r *RestrictParams,
|
||||||
|
source, target Vertex, amt lnwire.MilliSatoshi) (
|
||||||
|
[]*channeldb.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
// Hop represents an intermediate or final node of the route. This naming
|
// Hop represents an intermediate or final node of the route. This naming
|
||||||
// is in line with the definition given in BOLT #4: Onion Routing Protocol.
|
// is in line with the definition given in BOLT #4: Onion Routing Protocol.
|
||||||
// The struct houses the channel along which this hop can be reached and
|
// The struct houses the channel along which this hop can be reached and
|
||||||
|
@ -33,6 +33,8 @@ type paymentSession struct {
|
|||||||
|
|
||||||
haveRoutes bool
|
haveRoutes bool
|
||||||
preBuiltRoutes []*Route
|
preBuiltRoutes []*Route
|
||||||
|
|
||||||
|
pathFinder pathFinder
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReportVertexFailure adds a vertex to the graph prune view after a client
|
// ReportVertexFailure adds a vertex to the graph prune view after a client
|
||||||
@ -141,7 +143,7 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
|
|||||||
// Taking into account this prune view, we'll attempt to locate a path
|
// Taking into account this prune view, we'll attempt to locate a path
|
||||||
// to our destination, respecting the recommendations from
|
// to our destination, respecting the recommendations from
|
||||||
// missionControl.
|
// missionControl.
|
||||||
path, err := findPath(
|
path, err := p.pathFinder(
|
||||||
&graphParams{
|
&graphParams{
|
||||||
graph: p.mc.graph,
|
graph: p.mc.graph,
|
||||||
additionalEdges: p.additionalEdges,
|
additionalEdges: p.additionalEdges,
|
||||||
|
Loading…
Reference in New Issue
Block a user