routing: use probability source in path finding
This PR replaces the previously used edge and node ignore lists in path finding by a probability based system. It modifies path finding so that it not only compares routes on fee and time lock, but also takes route success probability into account. Allowing routes to be compared based on success probability is achieved by introducing a 'virtual' cost of a payment attempt and using that to translate probability into another cost factor.
This commit is contained in:
7 files changed
+327
-118
No files matched your search
@@ -143,6 +143,20 @@ func (p *paymentSession) ReportEdgePolicyFailure(
|
||||
p.errFailedPolicyChans[*failedEdge] = struct{}{}
|
||||
}
|
||||
|
||||
func (p *paymentSession) getEdgeProbability(node route.Vertex,
|
||||
edge EdgeLocator) float64 {
|
||||
|
||||
if _, ok := p.pruneViewSnapshot.vertexes[node]; ok {
|
||||
return 0
|
||||
}
|
||||
|
||||
if _, ok := p.pruneViewSnapshot.edges[edge]; ok {
|
||||
return 0
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
// RequestRoute returns a route which is likely to be capable for successfully
|
||||
// routing the specified HTLC payment to the target node. Initially the first
|
||||
// set of paths returned from this method may encounter routing failure along
|
||||
@@ -200,11 +214,11 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
|
||||
bandwidthHints: p.bandwidthHints,
|
||||
},
|
||||
&RestrictParams{
|
||||
IgnoredNodes: pruneView.vertexes,
|
||||
IgnoredEdges: pruneView.edges,
|
||||
FeeLimit: payment.FeeLimit,
|
||||
OutgoingChannelID: payment.OutgoingChannelID,
|
||||
CltvLimit: cltvLimit,
|
||||
ProbabilitySource: p.getEdgeProbability,
|
||||
FeeLimit: payment.FeeLimit,
|
||||
OutgoingChannelID: payment.OutgoingChannelID,
|
||||
CltvLimit: cltvLimit,
|
||||
PaymentAttemptPenalty: DefaultPaymentAttemptPenalty,
|
||||
},
|
||||
p.mc.selfNode.PubKeyBytes, payment.Target,
|
||||
payment.Amount,
|
||||
|
||||
Reference in new issue
Block a user