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:
Joost Jager committed 2019-06-04 10:00:21 +02:00
1 parent b6102ad191
commit 6b70791c2d
7 files changed
+327 -118

No files matched your search

+17 -12
View File
@@ -39,6 +39,11 @@ func TestQueryRoutes(t *testing.T) {
t.Fatal(err)
}
ignoredEdge := routing.EdgeLocator{
ChannelID: 555,
Direction: 1,
}
request := &lnrpc.QueryRoutesRequest{
PubKey: destKey,
Amt: 100000,
@@ -75,22 +80,22 @@ func TestQueryRoutes(t *testing.T) {
t.Fatal("unexpected fee limit")
}
if len(restrictions.IgnoredEdges) != 1 {
t.Fatal("unexpected ignored edges map size")
if restrictions.ProbabilitySource(route.Vertex{},
ignoredEdge,
) != 0 {
t.Fatal("expecting 0% probability for ignored edge")
}
if _, ok := restrictions.IgnoredEdges[routing.EdgeLocator{
ChannelID: 555, Direction: 1,
}]; !ok {
t.Fatal("unexpected ignored edge")
if restrictions.ProbabilitySource(ignoreNodeVertex,
routing.EdgeLocator{},
) != 0 {
t.Fatal("expecting 0% probability for ignored node")
}
if len(restrictions.IgnoredNodes) != 1 {
t.Fatal("unexpected ignored nodes map size")
}
if _, ok := restrictions.IgnoredNodes[ignoreNodeVertex]; !ok {
t.Fatal("unexpected ignored node")
if restrictions.ProbabilitySource(route.Vertex{},
routing.EdgeLocator{},
) != 1 {
t.Fatal("expecting 100% probability")
}
hops := []*route.Hop{{}}