Skip to content

Commit 77e3df0

Browse files
committed
gossipd: remove assert which can trigger.
We can actually fail to find a shorter route, but it's a fairly obscure case. Fixes: #3517 Signed-off-by: Rusty Russell <[email protected]>
1 parent 243078a commit 77e3df0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

gossipd/routing.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,10 +1217,19 @@ find_shorter_route(const tal_t *ctx, struct routing_state *rstate,
12171217
unvisited, shortest_cost_function);
12181218
dijkstra_cleanup(unvisited);
12191219

1220-
/* This must succeed, since we found a route before */
1220+
/* This will usually succeed, since we found a route before; however
1221+
* it's possible that it fails in corner cases. Consider that the reduced
1222+
* riskfactor may make us select a more fee-expensive route, which then
1223+
* makes us unable to complete the route due to htlc_max restrictions. */
12211224
short_route = build_route(ctx, rstate, dst, src, me, riskfactor, 1,
12221225
fuzz, base_seed, fee);
1223-
assert(short_route);
1226+
if (!short_route) {
1227+
status_info("Could't find short enough route %s->%s",
1228+
type_to_string(tmpctx, struct node_id, &dst->id),
1229+
type_to_string(tmpctx, struct node_id, &src->id));
1230+
goto out;
1231+
}
1232+
12241233
if (!amount_msat_sub(&short_cost,
12251234
dst->dijkstra.total, src->dijkstra.total))
12261235
goto bad_total;

0 commit comments

Comments
 (0)