mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
common/dijkstra: hand channel direction to path_score callback.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
e733fdf62e
commit
0b3c79b3c2
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user