| 3052 | } |
| 3053 | |
| 3054 | static struct command_result *routehint_step_cb(struct routehints_data *d, struct payment *p) |
| 3055 | { |
| 3056 | struct route_hop hop; |
| 3057 | const struct payment *root = payment_root(p); |
| 3058 | struct gossmap *map; |
| 3059 | if (p->step == PAYMENT_STEP_INITIALIZED) { |
| 3060 | if (root->routes == NULL) |
| 3061 | return payment_continue(p); |
| 3062 | |
| 3063 | /* We filter out non-functional routehints once at the |
| 3064 | * beginning, and every other payment will filter out the |
| 3065 | * exluded ones on the fly. */ |
| 3066 | if (p->parent == NULL) { |
| 3067 | map = get_gossmap(p); |
| 3068 | d->routehints = filter_routehints( |
| 3069 | map, p, d, p->local_id, p->routes); |
| 3070 | /* filter_routehints modifies the array, but |
| 3071 | * this could trigger a resize and the resize |
| 3072 | * could trigger a realloc. |
| 3073 | * Keep the invoice pointer up-to-date. |
| 3074 | * FIXME: We should really consider that if we are |
| 3075 | * mutating p->routes, maybe we should |
| 3076 | * drop d->routehints and just use p->routes |
| 3077 | * directly. |
| 3078 | * It is probably not a good idea to *copy* the |
| 3079 | * routehints: other paymods are interested in |
| 3080 | * p->routes, and if the routehints system |
| 3081 | * itself adds or removes routehints from its |
| 3082 | * copy, the *actual* number of routehints that we |
| 3083 | * end up using is the one that the routehints paymod |
| 3084 | * is maintaining and traversing, and it is *that* |
| 3085 | * set of routehints that is the important one. |
| 3086 | * So rather than copying the array of routehints |
| 3087 | * in paymod, paymod should use (and mutate) the |
| 3088 | * p->routes array, and |
| 3089 | */ |
| 3090 | put_gossmap(p); |
| 3091 | p->routes = d->routehints; |
| 3092 | |
| 3093 | paymod_log(p, LOG_DBG, |
| 3094 | "After filtering routehints we're left with " |
| 3095 | "%zu usable hints", |
| 3096 | tal_count(d->routehints)); |
| 3097 | /* Do not continue normally, instead go and check if |
| 3098 | * we can reach the destination directly. */ |
| 3099 | return routehint_check_reachable(p); |
| 3100 | } |
| 3101 | |
| 3102 | routehint_pre_getroute(d, p); |
| 3103 | } else if (p->step == PAYMENT_STEP_GOT_ROUTE && d->current_routehint != NULL) { |
| 3104 | /* Now it's time to stitch the two partial routes together. */ |
| 3105 | struct amount_msat dest_amount, estimate; |
| 3106 | /* We do not have the exact final amount, however we |
| 3107 | * know that we should be able to use the channel in |
| 3108 | * the routehint, so let's fake it as being 2x the |
| 3109 | * amount we want to route. */ |
| 3110 | |
| 3111 | if(!amount_msat_mul(&estimate, p->final_amount, 2)) |
nothing calls this directly
no test coverage detected