diff options
| author | Adam Soltys <[email protected]> | 2023-09-19 07:34:50 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-09-19 07:34:50 -0700 |
| commit | fb45ea1f665c5fc750e1bd09e3cc23be9c695133 (patch) | |
| tree | a4520a872751cbae49168c302468411b8caf98d2 | |
| parent | 21431092d710bf155082e522620cc5ba4fab6c7c (diff) | |
| download | coinos-server-fb45ea1f665c5fc750e1bd09e3cc23be9c695133.tar.gz coinos-server-fb45ea1f665c5fc750e1bd09e3cc23be9c695133.zip | |
fail faster
| -rw-r--r-- | routes/payments.js | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/routes/payments.js b/routes/payments.js index 7a8659f5..9ed4c038 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -78,23 +78,19 @@ export default { p = await debit(payreq, total, maxfee, memo, user, types.lightning); - let checks = 0; - let check = async () => { - checks++; - try { let { pays } = await ln.listpays(payreq); let recordExists = !!(await g(`payment:${p.id}`)); let paymentFailed = - pays.length && pays[pays.length - 1].status === "failed"; + !pays.length || pays.every(p => p.status === "failed"); l("checking", payreq, recordExists, paymentFailed); if ( recordExists && - (paymentFailed || (checks > 5 && !pays.length)) + paymentFailed ) { await db.del(`payment:${p.id}`); |
