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

Function count_possible_destinations

devtools/topology.c:123–164  ·  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#if 0
149 else
150 printf("Can't reach %s (%u) if we exclude %s\n",
151 type_to_string(tmpctx, struct node_id,
152 gossmap_node_get_id(map, n)),
153 dijkstra_distance(dij, gossmap_node_idx(map, n)),
154 type_to_string(tmpctx, struct node_id,
155 gossmap_node_get_id(map, exclude)));
156#endif
157 }
158
159 /* Now double-check with flood-fill. */
160 bool *visited = tal_arrz(tmpctx, bool, gossmap_max_node_idx(map));
161 visit(map, start, exclude, visited);
162 assert(memcount(visited, tal_bytelen(visited), true) == num);
163 return num;
164}
165
166static bool measure_least_cost(struct gossmap *map,
167 struct gossmap_node *src,

Callers 1

measure_least_costFunction · 0.85

Calls 11

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

Tested by

no test coverage detected