What nodes can n reach without going through exclude? */
| 121 | |
| 122 | /* What nodes can n reach without going through exclude? */ |
| 123 | static 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 | |
| 166 | static bool measure_least_cost(struct gossmap *map, |
| 167 | struct gossmap_node *src, |
no test coverage detected