mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
autopilot: return early for empty graph
This fixes an issue where the diameter calculation would crash if the graph is empty.
This commit is contained in:
parent
9e6f0ef46b
commit
ed40eddafd
1 changed files with 5 additions and 0 deletions
|
@ -132,6 +132,11 @@ func (graph *SimpleGraph) shortestPathLengths(node int) map[int]uint32 {
|
|||
// thisLevel contains the nodes that are explored in the round.
|
||||
thisLevel := make([]int, 0, graphOrder)
|
||||
|
||||
// Abort if we have an empty graph.
|
||||
if len(graph.Adj) == 0 {
|
||||
return seen
|
||||
}
|
||||
|
||||
// We discover other nodes in a ring-like structure as long as we don't
|
||||
// have more nodes to explore.
|
||||
for len(nextLevel) > 0 {
|
||||
|
|
Loading…
Add table
Reference in a new issue