mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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:
@@ -143,7 +143,8 @@ dijkstra_(const tal_t *ctx,
|
|||||||
void *arg),
|
void *arg),
|
||||||
u64 (*path_score)(u32 distance,
|
u64 (*path_score)(u32 distance,
|
||||||
struct amount_msat cost,
|
struct amount_msat cost,
|
||||||
struct amount_msat risk),
|
struct amount_msat risk,
|
||||||
|
const struct gossmap_chan *c),
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct dijkstra *dij;
|
struct dijkstra *dij;
|
||||||
@@ -250,7 +251,7 @@ dijkstra_(const tal_t *ctx,
|
|||||||
risk = risk_price(cost, riskfactor,
|
risk = risk_price(cost, riskfactor,
|
||||||
cur_d->total_delay
|
cur_d->total_delay
|
||||||
+ c->half[!which_half].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)
|
if (score >= d->score)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ dijkstra_(const tal_t *ctx,
|
|||||||
void *arg),
|
void *arg),
|
||||||
u64 (*path_score)(u32 distance,
|
u64 (*path_score)(u32 distance,
|
||||||
struct amount_msat cost,
|
struct amount_msat cost,
|
||||||
struct amount_msat risk),
|
struct amount_msat risk,
|
||||||
|
const struct gossmap_chan *c),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
#define dijkstra(ctx, map, start, amount, riskfactor, channel_ok, \
|
#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 */
|
/* Prioritize distance over costs */
|
||||||
u64 route_score_shorter(u32 distance,
|
u64 route_score_shorter(u32 distance,
|
||||||
struct amount_msat cost,
|
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);
|
return costs_to_score(cost, risk) + ((u64)distance << 32);
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,8 @@ u64 route_score_shorter(u32 distance,
|
|||||||
/* Prioritize costs over distance */
|
/* Prioritize costs over distance */
|
||||||
u64 route_score_cheaper(u32 distance,
|
u64 route_score_cheaper(u32 distance,
|
||||||
struct amount_msat cost,
|
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;
|
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 */
|
/* Shortest path, with lower amount tiebreak */
|
||||||
u64 route_score_shorter(u32 distance,
|
u64 route_score_shorter(u32 distance,
|
||||||
struct amount_msat cost,
|
struct amount_msat cost,
|
||||||
struct amount_msat risk);
|
struct amount_msat risk,
|
||||||
|
const struct gossmap_chan *c UNUSED);
|
||||||
|
|
||||||
/* Cheapest path, with shorter path tiebreak */
|
/* Cheapest path, with shorter path tiebreak */
|
||||||
u64 route_score_cheaper(u32 distance,
|
u64 route_score_cheaper(u32 distance,
|
||||||
struct amount_msat cost,
|
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. */
|
/* Extract route tal_arr from completed dijkstra: NULL if none. */
|
||||||
struct route_hop *route_from_dijkstra(const tal_t *ctx,
|
struct route_hop *route_from_dijkstra(const tal_t *ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user