Skip to content

Commit 171d463

Browse files
committed
common/dijkstra: hand channel direction to path_score callback.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 6b8d3a0 commit 171d463

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

common/dijkstra.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ dijkstra_(const tal_t *ctx,
144144
u64 (*path_score)(u32 distance,
145145
struct amount_msat cost,
146146
struct amount_msat risk,
147+
int dir,
147148
const struct gossmap_chan *c),
148149
void *arg)
149150
{
@@ -251,7 +252,7 @@ dijkstra_(const tal_t *ctx,
251252
risk = risk_price(cost, riskfactor,
252253
cur_d->total_delay
253254
+ c->half[!which_half].delay);
254-
score = path_score(cur_d->distance + 1, cost, risk, c);
255+
score = path_score(cur_d->distance + 1, cost, risk, !which_half, c);
255256
if (score >= d->score)
256257
continue;
257258

common/dijkstra.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dijkstra_(const tal_t *ctx,
2424
u64 (*path_score)(u32 distance,
2525
struct amount_msat cost,
2626
struct amount_msat risk,
27+
int dir,
2728
const struct gossmap_chan *c),
2829
void *arg);
2930

common/route.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static u32 costs_to_score(struct amount_msat cost,
5252
u64 route_score_shorter(u32 distance,
5353
struct amount_msat cost,
5454
struct amount_msat risk,
55+
int dir UNUSED,
5556
const struct gossmap_chan *c UNUSED)
5657
{
5758
return costs_to_score(cost, risk) + ((u64)distance << 32);
@@ -61,6 +62,7 @@ u64 route_score_shorter(u32 distance,
6162
u64 route_score_cheaper(u32 distance,
6263
struct amount_msat cost,
6364
struct amount_msat risk,
65+
int dir UNUSED,
6466
const struct gossmap_chan *c UNUSED)
6567
{
6668
return ((u64)costs_to_score(cost, risk) << 32) + distance;

common/route.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ bool route_can_carry_even_disabled(const struct gossmap *map,
5757
u64 route_score_shorter(u32 distance,
5858
struct amount_msat cost,
5959
struct amount_msat risk,
60+
int dir UNUSED,
6061
const struct gossmap_chan *c UNUSED);
6162

6263
/* Cheapest path, with shorter path tiebreak */
6364
u64 route_score_cheaper(u32 distance,
6465
struct amount_msat cost,
6566
struct amount_msat risk,
67+
int dir UNUSED,
6668
const struct gossmap_chan *c UNUSED);
6769

6870
/* Extract route tal_arr from completed dijkstra: NULL if none. */

plugins/topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct exclude_entry {
5252
static u64 route_score_fuzz(u32 distance,
5353
struct amount_msat cost,
5454
struct amount_msat risk,
55+
int dir UNUSED,
5556
const struct gossmap_chan *c)
5657
{
5758
u64 costs = cost.millisatoshis + risk.millisatoshis; /* Raw: score */

0 commit comments

Comments
 (0)