mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user