paymod: Consider new payments when checking if an attempt is ongoing

Without this the flapping behavior tested in `test_pay_retry` would reappear.
This commit is contained in:
Christian Decker
2020-05-27 14:49:40 +02:00
parent 7a266b8239
commit 2acb86bfe3

View File

@@ -1507,7 +1507,11 @@ static struct command_result *json_paystatus(struct command *cmd,
static bool attempt_ongoing(const char *b11)
{
struct pay_status *ps;
struct payment *root;
struct pay_attempt *attempt;
struct payment_tree_result res;
enum payment_step diff,
final_states = PAYMENT_STEP_FAILED | PAYMENT_STEP_SUCCESS;
list_for_each(&pay_status, ps, list) {
if (!streq(b11, ps->bolt11))
@@ -1515,6 +1519,14 @@ static bool attempt_ongoing(const char *b11)
attempt = &ps->attempts[tal_count(ps->attempts)-1];
return attempt->result == NULL && attempt->failure == NULL;
}
list_for_each(&payments, root, list) {
if (root->bolt11 == NULL || !streq(b11, root->bolt11))
continue;
res = payment_collect_result(root);
diff = res.leafstates & ~final_states;
return diff != 0;
}
return false;
}