routing: pop heap at the end of the loop

This prepares for routing to self.
This commit is contained in:
Joost Jager 2019-11-18 10:00:16 +01:00
parent 683282fa24
commit 81b7798c03
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -530,25 +530,14 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
// TODO(roasbeef): also add path caching
// * similar to route caching, but doesn't factor in the amount
// To start, our target node will the sole item within our distance
// heap.
heap.Push(&nodeHeap, distance[target])
// The partial path that we start out with is a path that consists of
// just the target node.
partialPath := distance[target]
for {
nodesVisited++
// Fetch the node within the smallest distance from our source
// from the heap.
partialPath := heap.Pop(&nodeHeap).(*nodeWithDist)
pivot := partialPath.node
// If we've reached our source (or we don't have any incoming
// edges), then we're done here and can exit the graph
// traversal early.
if pivot == source {
break
}
// Create unified policies for all incoming connections.
u := newUnifiedPolicies(source, pivot, r.OutgoingChannelID)
@ -589,6 +578,17 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
if nodeHeap.Len() == 0 {
break
}
// Fetch the node within the smallest distance from our source
// from the heap.
partialPath = heap.Pop(&nodeHeap).(*nodeWithDist)
// If we've reached our source (or we don't have any incoming
// edges), then we're done here and can exit the graph
// traversal early.
if partialPath.node == source {
break
}
}
// Use the distance map to unravel the forward path from source to