Skip to content

Commit

Permalink
common/dijkstra: hand channel direction to path_score callback.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Sep 8, 2021
1 parent 6b8d3a0 commit 171d463
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/dijkstra.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,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)
{
Expand Down Expand Up @@ -251,7 +252,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;

Expand Down
1 change: 1 addition & 0 deletions common/dijkstra.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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);

Expand Down
2 changes: 2 additions & 0 deletions common/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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);
Expand All @@ -61,6 +62,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;
Expand Down
2 changes: 2 additions & 0 deletions common/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
1 change: 1 addition & 0 deletions plugins/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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 */
Expand Down

0 comments on commit 171d463

Please sign in to comment.