mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
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,
|
||||
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
||||
mc: m,
|
||||
pathFinder: findPath,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -240,6 +241,7 @@ func (m *missionControl) NewPaymentSessionFromRoutes(routes []*Route) *paymentSe
|
||||
preBuiltRoutes: routes,
|
||||
errFailedPolicyChans: make(map[EdgeLocator]struct{}),
|
||||
mc: m,
|
||||
pathFinder: findPath,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,11 @@ const (
|
||||
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
|
||||
// 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
|
||||
|
@ -33,6 +33,8 @@ type paymentSession struct {
|
||||
|
||||
haveRoutes bool
|
||||
preBuiltRoutes []*Route
|
||||
|
||||
pathFinder pathFinder
|
||||
}
|
||||
|
||||
// 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
|
||||
// to our destination, respecting the recommendations from
|
||||
// missionControl.
|
||||
path, err := findPath(
|
||||
path, err := p.pathFinder(
|
||||
&graphParams{
|
||||
graph: p.mc.graph,
|
||||
additionalEdges: p.additionalEdges,
|
||||
|
Loading…
Reference in New Issue
Block a user