routing: fix panic in inner loop of path finding
This commit seems to fix a sporadic error within the integration tests which would at times cause a panic when a payment as initiated. This issue was with the way were deleting from the middle of the slice of unvisited nodes within the graph. Assigning the last element to the middle would at times cause a panic the last element may be nil. To fix this, we now manually copy every item over by one, preserving the order of the slice, and possibly fixing the panic once and for all.
This commit is contained in:
parent
c61ea17df5
commit
ec0c7c5989
@ -285,7 +285,7 @@ func findRoute(graph *channeldb.ChannelGraph, target *btcec.PublicKey,
|
||||
|
||||
// Since we're going to visit this node, we can
|
||||
// remove it from the set of unvisited nodes.
|
||||
unvisited[i] = unvisited[len(unvisited)-1]
|
||||
copy(unvisited[i:], unvisited[i+1:])
|
||||
unvisited[len(unvisited)-1] = nil // Avoid GC leak.
|
||||
unvisited = unvisited[:len(unvisited)-1]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user