Skip to content

Commit

Permalink
paymod: Reset the step if we're waiting for a block
Browse files Browse the repository at this point in the history
This was causing the state flapping test to fail, since we were yielding
control of the io_loop, waiting for the blockheight to be reached, and not
setting the status beforehand. An interim `paystatus` call would then find a
failed leaf and deduce the entire payment failed. Setting it back to the
previous state keeps the overall payment pending while we wait.
  • Loading branch information
cdecker committed Jul 9, 2020
1 parent 1e7241e commit a384e69
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,12 @@ static void waitblockheight_cb(void *d, struct payment *p)
" seconds to catch up to block %d before retrying.",
time_to_sec(remaining), blockheight);

/* Set temporarily set the state of the payment to not failed, so
* interim status queries don't show this as terminally failed. We're
* in control for this payment so nobody else could be fooled by
* this. The callback will set it to retry anyway. */
payment_set_step(p, PAYMENT_STEP_RETRY);

req = jsonrpc_request_start(p->plugin, NULL, "waitblockheight",
waitblockheight_rpc_cb,
waitblockheight_rpc_cb, p);
Expand Down

0 comments on commit a384e69

Please sign in to comment.