From b61670fe23c3ac57e01b9f6b55f125f46f4cb504 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 30 Nov 2017 22:29:38 -0800 Subject: [PATCH] routing: during path finding skip edge if amount < edge.MinHTLC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we update path finding to skip an edge if the amount we’re trying to route through it is below the MinHTLC (in mSAT) value for that node. We also add a new test to exercise this behavior. In order for out test to work properly, we’ve modified the JSON to make the edge to Goku have a higher min HTLC value. --- routing/pathfind.go | 11 ++++++----- routing/testdata/basic_graph.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index 4cebf227..c75aa299 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -490,12 +490,11 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, // record the new better distance, and also populate // our "next hop" map with this edge. We'll also shave // off irrelevant edges by adding the sufficient - // capacity of an edge to our relaxation condition. + // capacity of an edge and clearing their min-htlc + // amount to our relaxation condition. if tempDist < distance[v].dist && - edgeInfo.Capacity >= amt.ToSatoshis() { - - // TODO(roasbeef): need to also account - // for min HTLC + edgeInfo.Capacity >= amt.ToSatoshis() && + amt >= outEdge.MinHTLC { distance[v] = nodeWithDist{ dist: tempDist, @@ -518,6 +517,8 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, heap.Push(&nodeHeap, distance[v]) } + // TODO(roasbeef): return min HTLC as error in end? + return nil }) if err != nil { diff --git a/routing/testdata/basic_graph.json b/routing/testdata/basic_graph.json index 06feebfe..64849b63 100644 --- a/routing/testdata/basic_graph.json +++ b/routing/testdata/basic_graph.json @@ -64,7 +64,7 @@ "channel_point": "89dc56859c6a082d15ba1a7f6cb6be3fea62e1746e2cb8497b1189155c21a233:0", "flags": 0, "expiry": 1, - "min_htlc": 1, + "min_htlc": 1000, "fee_base_msat": 10, "fee_rate": 1000, "capacity": 100000