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

Function count_possible_sources

devtools/topology.c:46–71  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

44
45/* What nodes can reach n without going through exclude? */
46static size_t count_possible_sources(const struct gossmap *map,
47 struct gossmap_node *n,
48 struct gossmap_node *exclude,
49 bool is_last_node)
50{
51 const struct dijkstra *dij;
52 size_t distance_budget, num;
53
54 dij = dijkstra(tmpctx, map, n, AMOUNT_MSAT(0), 0,
55 channel_usable_to_excl, route_score_shorter, exclude);
56
57 if (is_last_node)
58 distance_budget = ROUTING_MAX_HOPS - 1;
59 else
60 distance_budget = ROUTING_MAX_HOPS - 2;
61
62 assert(dijkstra_distance(dij, gossmap_node_idx(map, n)) == 0);
63 assert(dijkstra_distance(dij, gossmap_node_idx(map, exclude)) == UINT_MAX);
64
65 num = 0;
66 for (n = gossmap_first_node(map); n; n = gossmap_next_node(map, n)) {
67 if (dijkstra_distance(dij, gossmap_node_idx(map, n)) <= distance_budget)
68 num++;
69 }
70 return num;
71}
72
73/* Note: dijkstra() sets dir to the neighbor side; i.e. c->half[dir].node_idx is the
74 * neighbor. */

Callers 1

measure_least_costFunction · 0.85

Calls 5

dijkstra_distanceFunction · 0.85
gossmap_node_idxFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85
dijkstraClass · 0.70

Tested by

no test coverage detected