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