common/dijkstra: hand channel direction to path_score callback.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-09-23 22:36:09 +09:30
committed by Christian Decker
parent e733fdf62e
commit 0b3c79b3c2
5 changed files with 8 additions and 1 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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. */

View File

@@ -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 */