We won't try sending any more. Usually this means we return this * failure to the user, but see below. */
| 504 | /* We won't try sending any more. Usually this means we return this |
| 505 | * failure to the user, but see below. */ |
| 506 | static void payment_give_up(struct command *aux_cmd, |
| 507 | struct payment *payment, |
| 508 | enum jsonrpc_errcode code, |
| 509 | const char *fmt, |
| 510 | ...) |
| 511 | { |
| 512 | va_list args; |
| 513 | const char *msg; |
| 514 | |
| 515 | va_start(args, fmt); |
| 516 | msg = tal_vfmt(tmpctx, fmt, args); |
| 517 | va_end(args); |
| 518 | |
| 519 | /* Only fail once */ |
| 520 | if (payment->cmd && should_finish_command(payment)) { |
| 521 | const struct preimage *preimage; |
| 522 | |
| 523 | /* Corner case: in slow_mode, an earlier one could have |
| 524 | * theoretically succeeded. */ |
| 525 | preimage = any_attempts_succeeded(payment); |
| 526 | if (preimage) |
| 527 | payment_succeeded(payment, preimage); |
| 528 | else { |
| 529 | was_pending(command_fail(payment->cmd, code, "%s", msg)); |
| 530 | payment->cmd = NULL; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /* If no commands outstanding, we can now clean up */ |
| 535 | if (tal_count(payment->requests) == 0) |
| 536 | cleanup(aux_cmd, payment); |
| 537 | } |
| 538 | |
| 539 | static void add_result_summary(struct attempt *attempt, |
| 540 | enum log_level level, |
no test coverage detected