MCPcopy Create free account
hub / github.com/ElementsProject/lightning / count_possible_destinations

Function count_possible_destinations

devtools/topology.c:123–155  ·  view source on GitHub ↗

What nodes can n reach without going through exclude? */

Source from the content-addressed store, hash-verified

121
122/* What nodes can n reach without going through exclude? */
123static size_t count_possible_destinations(const struct gossmap *map,
124 struct gossmap_node *start,
125 struct gossmap_node *exclude,
126 bool is_first_node)
127{
128 const struct dijkstra *dij;
129 size_t distance_budget, num;
130
131 dij = dijkstra(tmpctx, map, start, AMOUNT_MSAT(0), 0,
132 channel_usable_from_excl, route_score_shorter, exclude);
133
134 if (is_first_node)
135 distance_budget = ROUTING_MAX_HOPS - 1;
136 else
137 distance_budget = ROUTING_MAX_HOPS - 2;
138
139 assert(dijkstra_distance(dij, gossmap_node_idx(map, start)) == 0);
140 assert(dijkstra_distance(dij, gossmap_node_idx(map, exclude)) == UINT_MAX);
141
142 num = 0;
143 for (struct gossmap_node *n = gossmap_first_node(map);
144 n;
145 n = gossmap_next_node(map, n)) {
146 if (dijkstra_distance(dij, gossmap_node_idx(map, n)) <= distance_budget)
147 num++;
148 }
149
150 /* Now double-check with flood-fill. */
151 bool *visited = tal_arrz(tmpctx, bool, gossmap_max_node_idx(map));
152 visit(map, start, exclude, visited);
153 assert(memcount(visited, tal_bytelen(visited), true) == num);
154 return num;
155}
156
157static bool measure_least_cost(struct gossmap *map,
158 struct gossmap_node *src,

Callers 1

measure_least_costFunction · 0.85

Calls 9

dijkstra_distanceFunction · 0.85
gossmap_node_idxFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
gossmap_max_node_idxFunction · 0.85
memcountFunction · 0.85
tal_bytelenFunction · 0.85
dijkstraClass · 0.70
visitFunction · 0.70

Tested by

no test coverage detected