routing: add sufficient link capacity to our relaxation condition

This commit modifies our modified version of Dijkstra's to include
sufficient link capacity within the algorithm’s relaxation condition.
With this change, we’ll now avoid exploring the graph in the direction
of a link that has insufficient capacity, allowing us to terminate path
finding more quickly.
This commit is contained in:
Olaoluwa Osuntokun 2017-03-19 14:11:25 -07:00
parent 606b23df43
commit 20aba8060f
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 8 additions and 2 deletions

@ -331,7 +331,9 @@ func findRoute(graph *channeldb.ChannelGraph, target *btcec.PublicKey,
// TODO(roasbeef): add capacity to relaxation criteria?
// * also add min payment?
v := newVertex(edge.Node.PubKey)
if tempDist < distance[v].dist {
if tempDist < distance[v].dist &&
edgeInfo.Capacity >= amt {
distance[v] = nodeWithDist{
dist: tempDist,
node: edge.Node,

@ -431,11 +431,15 @@ func TestPathInsufficientCapacity(t *testing.T) {
const payAmt = btcutil.SatoshiPerBitcoin
_, err = findRoute(graph, target, payAmt)
if err != ErrInsufficientCapacity {
if err != ErrNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err)
}
}
func TestPathInsufficientCapacityWithFee(t *testing.T) {
// TODO(roasbeef): encode live graph to json
// TODO(roasbeef): need to add a case, or modify the fee ratio for one
// to ensure that has going forward, but when fees are applied doesn't
// work
}