Skip to content

Commit

Permalink
Set invoice.updated_at to date slightly in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Feb 13, 2025
1 parent ddc115e commit a485faf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions worker/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
subscribeToInvoices, subscribeToPayments, subscribeToInvoice
} from 'ln-service'
import { getPaymentOrNotSent } from '@/api/lnd'
import { sleep } from '@/lib/time'
import { datePivot, sleep } from '@/lib/time'
import retry from 'async-retry'
import {
paidActionPaid, paidActionForwarded,
Expand Down Expand Up @@ -162,7 +162,14 @@ export async function checkInvoice ({ data: { hash, invoice }, boss, models, lnd
}

export async function retryTimeout ({ data: { hash }, models, lnd, boss }) {
await models.invoice.update({ where: { hash }, data: { updatedAt: new Date() } })
// This job exists to make sure the notification indicator shows up when
// 1) not enough automated retries have been attempted
// and
// 2) no more automated retries will be attempted because invoice is too old
// since the notification indicator only checks invoices that have been updated since the last poll.
// We set the date slightly in future to avoid possibly possible (= not verified)
// race conditions between the notification indicator poll and this update.
await models.invoice.update({ where: { hash }, data: { updatedAt: datePivot(new Date(), { seconds: 5 }) } })
}

async function subscribeToWithdrawals (args) {
Expand Down

0 comments on commit a485faf

Please sign in to comment.