From 05f95b59c10aec63d3a8f4d9c69f580f25c76818 Mon Sep 17 00:00:00 2001 From: Rusty Russell <rusty@rustcorp.com.au> Date: Fri, 1 Feb 2019 16:23:38 +1030 Subject: [PATCH] gossipd: take into account risk in final route comparison. We were only comparing by total msatoshis. Note, this *still* isn't sufficient to fix our indirect problem, as our risk values are all 1 (the minimum): lightning_gossipd(25480): 2 hop solution: 1501990 + 2 lightning_gossipd(25480): 3 hop solution: 1501971 + 3 ... lightning_gossipd(25480): => chose 3 hop solution Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> --- CHANGELOG.md | 1 + gossipd/routing.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecbe90f78..47e7a8efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ changes. (eg. 4 billion) was slow due to a bug. - Fixed occasional deadlock with peers when exchanging huge amounts of gossip. - You can no longer make giant unpayable "wumbo" invoices. +- CLTV of total route now correctly evaluated when finding best route. ### Security diff --git a/gossipd/routing.c b/gossipd/routing.c index 1a23dd8c8..5fcf2a2b8 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -529,9 +529,13 @@ find_route(const tal_t *ctx, struct routing_state *rstate, best = 0; for (i = 1; i <= max_hops; i++) { - if (dst->bfg[i].total < dst->bfg[best].total) + status_trace("%i hop solution: %"PRIu64" + %"PRIu64, + i, dst->bfg[i].total, dst->bfg[i].risk); + if (dst->bfg[i].total + dst->bfg[i].risk + < dst->bfg[best].total + dst->bfg[best].risk) best = i; } + status_trace("=> chose %i hop solution", best); /* No route? */ if (dst->bfg[best].total >= INFINITE) {