| 2992 | } |
| 2993 | |
| 2994 | static struct command_result *routehint_check_reachable(struct payment *p) |
| 2995 | { |
| 2996 | const struct gossmap_node *dst, *src; |
| 2997 | struct gossmap *gossmap = get_gossmap(p); |
| 2998 | const struct dijkstra *dij; |
| 2999 | struct route_hop *r; |
| 3000 | struct payment *root = payment_root(p); |
| 3001 | struct routehints_data *d = payment_mod_routehints_get_data(root); |
| 3002 | |
| 3003 | /* Start a tiny exploratory route computation, so we know |
| 3004 | * whether we stand any chance of reaching the destination |
| 3005 | * without routehints. This will later be used to mix in |
| 3006 | * attempts without routehints. */ |
| 3007 | src = gossmap_find_node(gossmap, p->local_id); |
| 3008 | dst = gossmap_find_node(gossmap, p->route_destination); |
| 3009 | if (dst == NULL) |
| 3010 | d->destination_reachable = false; |
| 3011 | else if (src != NULL) { |
| 3012 | dij = dijkstra(tmpctx, gossmap, dst, AMOUNT_MSAT(0), |
| 3013 | 10 / 1000000.0, |
| 3014 | payment_route_can_carry_even_disabled, |
| 3015 | route_score_cheaper, p); |
| 3016 | r = route_from_dijkstra(tmpctx, gossmap, dij, src, |
| 3017 | AMOUNT_MSAT(0), 0); |
| 3018 | |
| 3019 | /* If there was a route the destination is reachable |
| 3020 | * without routehints. */ |
| 3021 | d->destination_reachable = r != NULL; |
| 3022 | } else { |
| 3023 | paymod_log(p, LOG_DBG, |
| 3024 | "Could not locate ourselves in the network. " |
| 3025 | "Allowing direct attempts"); |
| 3026 | d->destination_reachable = true; |
| 3027 | } |
| 3028 | |
| 3029 | if (d->destination_reachable) { |
| 3030 | tal_arr_expand(&d->routehints, NULL); |
| 3031 | /* The above could trigger a realloc. |
| 3032 | * However, p->routes and d->routehints are |
| 3033 | * actually the same array, so we need to update the |
| 3034 | * p->routes pointer, since the realloc |
| 3035 | * might have changed pointer addresses, in order to |
| 3036 | * ensure that the pointers are not stale. |
| 3037 | */ |
| 3038 | p->routes = d->routehints; |
| 3039 | |
| 3040 | /* FIXME: ***DO*** we need to add this extra routehint? |
| 3041 | * Once we run out of routehints the default system will |
| 3042 | * just attempt directly routing to the destination anyway. */ |
| 3043 | } else if (tal_count(d->routehints) == 0) { |
| 3044 | /* If we don't have any routehints and the destination |
| 3045 | * isn't reachable, then there is no point in |
| 3046 | * continuing. */ |
| 3047 | |
| 3048 | put_gossmap(p); |
| 3049 | return payment_abort( |
| 3050 | p, |
| 3051 | PAY_UNREACHABLE, |
no test coverage detected