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

Optimize keysend/multikeysend balance checks #452

Closed kiwiidb closed 11 months ago

kiwiidb commented 11 months ago

Currently, we do a CheckPaymentAllowed for every split in the multikeysend.

This can put a lot of pressure on the database when someone with a large account is doing a lot of multikeysend requests. We could move the CheckPaymentAllowed check one level up, into both the KeySend and MultiKeySend controller methods. For the MultiKeysend, we can create a "synthetic" LNPayReq object with the amount being the total amount in the multikeysend request. Like this we can decrease the load on the database significantly.

kiwiidb commented 11 months ago

fixed in #454