From 0b3c79b3c2be6037c76f9427b1158cfaa76f4d29 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 23 Sep 2021 22:36:09 +0930 Subject: [PATCH] common/dijkstra: hand channel direction to path_score callback. Signed-off-by: Rusty Russell --- common/dijkstra.c | 3 ++- common/dijkstra.h | 1 + common/route.c | 2 ++ common/route.h | 2 ++ plugins/topology.c | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common/dijkstra.c b/common/dijkstra.c index 31551a0db..e4d9c0ead 100644 --- a/common/dijkstra.c +++ b/common/dijkstra.c @@ -139,6 +139,7 @@ dijkstra_(const tal_t *ctx, u64 (*path_score)(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir, const struct gossmap_chan *c), void *arg) { @@ -246,7 +247,7 @@ dijkstra_(const tal_t *ctx, risk = risk_price(cost, riskfactor, cur_d->total_delay + c->half[!which_half].delay); - score = path_score(cur_d->distance + 1, cost, risk, c); + score = path_score(cur_d->distance + 1, cost, risk, !which_half, c); if (score >= d->score) continue; diff --git a/common/dijkstra.h b/common/dijkstra.h index 3672c59a8..788182cd6 100644 --- a/common/dijkstra.h +++ b/common/dijkstra.h @@ -22,6 +22,7 @@ dijkstra_(const tal_t *ctx, u64 (*path_score)(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir, const struct gossmap_chan *c), void *arg); diff --git a/common/route.c b/common/route.c index a24b26da4..f204518b7 100644 --- a/common/route.c +++ b/common/route.c @@ -44,6 +44,7 @@ static u32 costs_to_score(struct amount_msat cost, u64 route_score_shorter(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir UNUSED, const struct gossmap_chan *c UNUSED) { return costs_to_score(cost, risk) + ((u64)distance << 32); @@ -53,6 +54,7 @@ u64 route_score_shorter(u32 distance, u64 route_score_cheaper(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir UNUSED, const struct gossmap_chan *c UNUSED) { return ((u64)costs_to_score(cost, risk) << 32) + distance; diff --git a/common/route.h b/common/route.h index 5528d5390..1fc474234 100644 --- a/common/route.h +++ b/common/route.h @@ -57,12 +57,14 @@ bool route_can_carry_even_disabled(const struct gossmap *map, u64 route_score_shorter(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir UNUSED, const struct gossmap_chan *c UNUSED); /* Cheapest path, with shorter path tiebreak */ u64 route_score_cheaper(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir UNUSED, const struct gossmap_chan *c UNUSED); /* Extract route tal_arr from completed dijkstra: NULL if none. */ diff --git a/plugins/topology.c b/plugins/topology.c index 11462fc22..3d30582d6 100644 --- a/plugins/topology.c +++ b/plugins/topology.c @@ -48,6 +48,7 @@ struct exclude_entry { static u64 route_score_fuzz(u32 distance, struct amount_msat cost, struct amount_msat risk, + int dir UNUSED, const struct gossmap_chan *c) { u64 costs = cost.millisatoshis + risk.millisatoshis; /* Raw: score */