| 2342 | } |
| 2343 | |
| 2344 | struct command_result *payment_continue(struct payment *p) |
| 2345 | { |
| 2346 | struct payment_modifier *mod; |
| 2347 | void *moddata; |
| 2348 | |
| 2349 | trace_span_start("payment_continue", p); |
| 2350 | /* If we are in the middle of calling the modifiers, continue calling |
| 2351 | * them, otherwise we can continue with the payment state-machine. */ |
| 2352 | p->current_modifier++; |
| 2353 | mod = p->modifiers[p->current_modifier]; |
| 2354 | |
| 2355 | if (mod != NULL) { |
| 2356 | char *str = tal_fmt(tmpctx, "%d", p->current_modifier); |
| 2357 | trace_span_tag(p, "modifier", str); |
| 2358 | trace_span_end(p); |
| 2359 | /* There is another modifier, so call it. */ |
| 2360 | moddata = p->modifier_data[p->current_modifier]; |
| 2361 | return mod->post_step_cb(moddata, p); |
| 2362 | } else { |
| 2363 | /* There are no more modifiers, so reset the call chain and |
| 2364 | * proceed to the next state. */ |
| 2365 | p->current_modifier = -1; |
| 2366 | trace_span_tag(p, "step", payment_step_str[p->step]); |
| 2367 | trace_span_end(p); |
| 2368 | switch (p->step) { |
| 2369 | case PAYMENT_STEP_INITIALIZED: |
| 2370 | case PAYMENT_STEP_RETRY_GETROUTE: |
| 2371 | return payment_getlocalmods(p); |
| 2372 | |
| 2373 | case PAYMENT_STEP_GOT_ROUTE: |
| 2374 | return payment_compute_onion_payloads(p); |
| 2375 | |
| 2376 | case PAYMENT_STEP_ONION_PAYLOAD: |
| 2377 | return payment_sendonion(p); |
| 2378 | |
| 2379 | case PAYMENT_STEP_SUCCESS: |
| 2380 | case PAYMENT_STEP_FAILED: |
| 2381 | return payment_finished(p); |
| 2382 | |
| 2383 | case PAYMENT_STEP_RETRY: |
| 2384 | case PAYMENT_STEP_SPLIT: |
| 2385 | /* Do nothing, we'll get pinged by a child succeeding |
| 2386 | * or failing. */ |
| 2387 | return command_still_pending(payment_cmd(p)); |
| 2388 | } |
| 2389 | } |
| 2390 | trace_span_end(p); |
| 2391 | /* We should never get here, it'd mean one of the state machine called |
| 2392 | * `payment_continue` after the final state. */ |
| 2393 | abort(); |
| 2394 | } |
| 2395 | |
| 2396 | struct command_result *payment_abort(struct payment *p, enum jsonrpc_errcode code, const char *fmt, ...) { |
| 2397 | va_list ap; |
no test coverage detected