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

@@ -27,20 +27,14 @@ bool route_can_carry_even_disabled(const struct gossmap *map,
void *unused);
/* Shortest path, with lower amount tiebreak */
bool route_path_shorter(u32 old_distance, u32 new_distance,
struct amount_msat old_cost,
struct amount_msat new_cost,
struct amount_msat old_risk,
struct amount_msat new_risk,
void *unused);
u64 route_score_shorter(u32 distance,
struct amount_msat cost,
struct amount_msat risk);
/* Cheapest path, with shorter path tiebreak */
bool route_path_cheaper(u32 old_distance, u32 new_distance,
struct amount_msat old_cost,
struct amount_msat new_cost,
struct amount_msat old_risk,
struct amount_msat new_risk,
void *unused);
u64 route_score_cheaper(u32 distance,
struct amount_msat cost,
struct amount_msat risk);
/* Extract route tal_arr from completed dijkstra */
struct route **route_from_dijkstra(const struct gossmap *map,