From 5ef077e5c8b53a2a7576abdf220420643e94e23d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 15 Aug 2017 19:56:28 -0700 Subject: [PATCH] routing: cap number of yen's algorithm iterations at 100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit makes a precautionary change in order to ensure that the upper bound on the number of iteration’s within our version of Yen’s algorithm is fixed. --- routing/pathfind.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index 2571278f..e41ff1f0 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -536,7 +536,7 @@ func findPaths(graph *channeldb.ChannelGraph, source *channeldb.LightningNode, // While we still have candidate paths to explore we'll keep exploring // the sub-graphs created to find the next k-th shortest path. - for k := 1; k == 1 || candidatePaths.Len() != 0; k++ { + for k := 1; k < 100; k++ { prevShortest := shortestPaths[k-1] // We'll examine each edge in the previous iteration's shortest @@ -605,6 +605,8 @@ func findPaths(graph *channeldb.ChannelGraph, source *channeldb.LightningNode, newPath.hops = append(newPath.hops, rootPath...) newPath.hops = append(newPath.hops, spurPath...) + // TODO(roasbeef): add and consult path finger print + // We'll now add this newPath to the heap of candidate // shortest paths. heap.Push(&candidatePaths, newPath)