mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-03 19:53:09 +02:00
sqldb+invoices: Optimize invoice fetching when the reference is only a hash
The current sqlc GetInvoice query experiences incremental slowdowns during the migration of large invoice databases, primarily due to its complex predicate set. For this specific use case, a streamlined GetInvoiceByHash function provides a more efficient solution, maintaining near-constant lookup times even with extensive table sizes.
This commit is contained in:
@@ -187,6 +187,11 @@ func (r InvoiceRef) Modifier() RefModifier {
|
||||
return r.refModifier
|
||||
}
|
||||
|
||||
// IsHashOnly returns true if the invoice ref only contains a payment hash.
|
||||
func (r InvoiceRef) IsHashOnly() bool {
|
||||
return r.payHash != nil && r.payAddr == nil && r.setID == nil
|
||||
}
|
||||
|
||||
// String returns a human-readable representation of an InvoiceRef.
|
||||
func (r InvoiceRef) String() string {
|
||||
var ids []string
|
||||
|
Reference in New Issue
Block a user