mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
dijkstra: add chan pointer argument to path scoring.
For fuzz, we will need some fixed per-channel data (so we always fuzz a channel the same way). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3832542d27
commit
46b735c023
4 changed files with 13 additions and 7 deletions
|
@ -143,7 +143,8 @@ dijkstra_(const tal_t *ctx,
|
|||
void *arg),
|
||||
u64 (*path_score)(u32 distance,
|
||||
struct amount_msat cost,
|
||||
struct amount_msat risk),
|
||||
struct amount_msat risk,
|
||||
const struct gossmap_chan *c),
|
||||
void *arg)
|
||||
{
|
||||
struct dijkstra *dij;
|
||||
|
@ -250,7 +251,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);
|
||||
score = path_score(cur_d->distance + 1, cost, risk, c);
|
||||
if (score >= d->score)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ dijkstra_(const tal_t *ctx,
|
|||
void *arg),
|
||||
u64 (*path_score)(u32 distance,
|
||||
struct amount_msat cost,
|
||||
struct amount_msat risk),
|
||||
struct amount_msat risk,
|
||||
const struct gossmap_chan *c),
|
||||
void *arg);
|
||||
|
||||
#define dijkstra(ctx, map, start, amount, riskfactor, channel_ok, \
|
||||
|
|
|
@ -51,7 +51,8 @@ static u32 costs_to_score(struct amount_msat cost,
|
|||
/* Prioritize distance over costs */
|
||||
u64 route_score_shorter(u32 distance,
|
||||
struct amount_msat cost,
|
||||
struct amount_msat risk)
|
||||
struct amount_msat risk,
|
||||
const struct gossmap_chan *c UNUSED)
|
||||
{
|
||||
return costs_to_score(cost, risk) + ((u64)distance << 32);
|
||||
}
|
||||
|
@ -59,7 +60,8 @@ u64 route_score_shorter(u32 distance,
|
|||
/* Prioritize costs over distance */
|
||||
u64 route_score_cheaper(u32 distance,
|
||||
struct amount_msat cost,
|
||||
struct amount_msat risk)
|
||||
struct amount_msat risk,
|
||||
const struct gossmap_chan *c UNUSED)
|
||||
{
|
||||
return ((u64)costs_to_score(cost, risk) << 32) + distance;
|
||||
}
|
||||
|
|
|
@ -56,12 +56,14 @@ bool route_can_carry_even_disabled(const struct gossmap *map,
|
|||
/* Shortest path, with lower amount tiebreak */
|
||||
u64 route_score_shorter(u32 distance,
|
||||
struct amount_msat cost,
|
||||
struct amount_msat risk);
|
||||
struct amount_msat risk,
|
||||
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);
|
||||
struct amount_msat risk,
|
||||
const struct gossmap_chan *c UNUSED);
|
||||
|
||||
/* Extract route tal_arr from completed dijkstra: NULL if none. */
|
||||
struct route_hop *route_from_dijkstra(const tal_t *ctx,
|
||||
|
|
Loading…
Add table
Reference in a new issue