routing: during path finding skip edge if amount < edge.MinHTLC

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-30 22:29:38 -08:00
parent 73ccb76853
commit b61670fe23
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 7 additions and 6 deletions

@ -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 {

@ -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