routing: add min probability to path finding

This commit adds a new restriction to pathfinding that allows returning
only routes with a minimum success probability.
This commit is contained in:
Joost Jager committed 2019-06-04 10:00:23 +02:00
1 parent 6b70791c2d
commit 3349d517aa
2 files changed
+55 -9

No files matched your search

+15
View File
@@ -46,6 +46,10 @@ var (
// off potentially better routes against their probability of
// succeeding.
DefaultPaymentAttemptPenalty = lnwire.NewMSatFromSatoshis(100)
// DefaultMinProbability is the default minimum probability for routes
// returned from findPath.
DefaultMinProbability = float64(0.01)
)
// edgePolicyWithSource is a helper struct to keep track of the source node
@@ -258,6 +262,10 @@ type RestrictParams struct {
// off potentially better routes against their probability of
// succeeding.
PaymentAttemptPenalty lnwire.MilliSatoshi
// MinProbability defines the minimum success probability of the
// returned route.
MinProbability float64
}
// findPath attempts to find a path from the source node within the
@@ -465,6 +473,13 @@ func findPath(g *graphParams, r *RestrictParams, source, target route.Vertex,
// of the route must succeed.
probability := toNodeDist.probability * edgeProbability
// If the probability is below the specified lower bound, we can
// abandon this direction. Adding further nodes can only lower
// the probability more.
if probability < r.MinProbability {
return
}
// By adding fromNode in the route, there will be an extra
// weight composed of the fee that this node will charge and
// the amount that will be locked for timeLockDelta blocks in