getAlby / lndhub.go

Accounting wrapper for the Lightning Network. It provides separate accounts for end-users. (LndHub compatible API written in Go)
GNU General Public License v3.0
86 stars 23 forks source link

Invoice subscription: safety improvements #316

Closed kiwiidb closed 1 year ago

kiwiidb commented 1 year ago

Fixes #312 , fixes #313 This PR changes the behaviour of the invoice subscription routine in case of an error:

reneaaron commented 1 year ago

@kiwiidb Should we also add an index for the invoice subscription query, too? It's only a matter of time until this query takes longer than the timeout.

explain analyze select * from public.invoices where invoices.settled_at IS NULL AND invoices.add_index IS NOT NULL AND invoices.expires_at >= now() order by invoices.id ASC

leads to some really awful query plan as there are no indexes to be used currently.

I think we would need to add a combined column index on the used columns to speed this up.

bumi commented 1 year ago

@reneaaron of course :) indexes need to be pimped