mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
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:
parent
2bb365a931
commit
3832542d27
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user