common/dijkstra: remove dijkstra_amount().

Unless you're using amount as the sole cost function (we don't!), the
"cost" is not the "amount".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-05-22 16:40:01 +09:30
parent 2bb365a931
commit 3832542d27
4 changed files with 8 additions and 16 deletions

View File

@ -45,12 +45,6 @@ u32 dijkstra_delay(const struct dijkstra *dij, u32 node_idx)
return dij[node_idx].total_delay;
}
/* Total cost to get here. */
struct amount_msat dijkstra_amount(const struct dijkstra *dij, u32 node_idx)
{
return dij[node_idx].cost;
}
struct gossmap_chan *dijkstra_best_chan(const struct dijkstra *dij,
u32 node_idx)
{

View File

@ -42,9 +42,6 @@ u32 dijkstra_distance(const struct dijkstra *dij, u32 node_idx);
/* Total CLTV delay (0 if unreachable) */
u32 dijkstra_delay(const struct dijkstra *dij, u32 node_idx);
/* Total cost to get here (-1ULL if unreachable) */
struct amount_msat dijkstra_amount(const struct dijkstra *dij, u32 node_idx);
/* Best path we found to here */
struct gossmap_chan *dijkstra_best_chan(const struct dijkstra *dij,
u32 node_idx);

View File

@ -48,12 +48,12 @@ static struct route_hop *least_cost(struct gossmap *map,
}
if (!amount_msat_add(&maxcost, sent, budget))
abort();
if (amount_msat_greater(dijkstra_amount(dij, srcidx), maxcost)) {
path = route_from_dijkstra(map, map, dij, src, sent, 0);
if (amount_msat_greater(path[0].amount, maxcost)) {
printf("failed (too expensive)\n");
return NULL;
return tal_free(path);
}
path = route_from_dijkstra(map, map, dij, src, sent, 0);
printf("# path length %zu\n", tal_count(path));
/* We don't pay fee on first hop! */
if (!amount_msat_sub(&fee, path[0].amount, sent))

View File

@ -205,14 +205,15 @@ static bool measure_least_cost(struct gossmap *map,
}
if (!amount_msat_add(&maxcost, sent, budget))
abort();
if (amount_msat_greater(dijkstra_amount(dij, srcidx), maxcost)) {
path = route_from_dijkstra(map, map, dij, src, sent, 0);
if (amount_msat_greater(path[0].amount, maxcost)) {
printf("failed (too expensive)\n");
return false;
}
path = route_from_dijkstra(map, map, dij, src, sent, 0);
printf("# path length %zu\n", tal_count(path));
if (!amount_msat_sub(&fee, dijkstra_amount(dij, srcidx), sent))
if (!amount_msat_sub(&fee, path[0].amount, sent))
abort();
printf("# path fee %s\n",
type_to_string(tmpctx, struct amount_msat, &fee));