dijkstra: fix heap ordering.

We were always ordering heap by distance, not score (which are different
if we are routing by cheapest, not shortest!).

This simplifies our callbacks, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-10-20 14:28:06 +10:30
parent 4a1843a151
commit 1bf3eebbf6
6 changed files with 49 additions and 85 deletions

View File

@@ -55,7 +55,7 @@ static size_t count_possible_sources(const struct gossmap *map,
size_t distance_budget, num;
dij = dijkstra(tmpctx, map, n, AMOUNT_MSAT(0), 0,
channel_usable_to_excl, route_path_shorter, exclude);
channel_usable_to_excl, route_score_shorter, exclude);
if (is_last_node)
distance_budget = ROUTING_MAX_HOPS - 1;
@@ -132,7 +132,7 @@ static size_t count_possible_destinations(const struct gossmap *map,
size_t distance_budget, num;
dij = dijkstra(tmpctx, map, start, AMOUNT_MSAT(0), 0,
channel_usable_from_excl, route_path_shorter, exclude);
channel_usable_from_excl, route_score_shorter, exclude);
if (is_first_node)
distance_budget = ROUTING_MAX_HOPS - 1;
@@ -191,7 +191,7 @@ static bool measure_least_cost(struct gossmap *map,
tstart = time_mono();
dij = dijkstra(tmpctx, map, dst,
sent, riskfactor, channel_usable,
route_path_cheaper, NULL);
route_score_cheaper, NULL);
tstop = time_mono();
printf("# Time to find path: %"PRIu64" usec\n",