lnd: reduce max limit when querying for payments

This commit is contained in:
ziggie committed 2025-09-05 09:54:00 +02:00
1 parent a9c30dacb5
commit 335a9b3f40
2 files changed
+14 -3

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
package paymentsdb
const (
// DefaultMaxPayments is the default maximum number of payments returned
// in the payments query pagination.
DefaultMaxPayments = 100
)
// Query represents a query to the payments database starting or ending
// at a certain offset index. The number of retrieved records can be limited.
type Query struct {
+8 -3
View File
@@ -7523,10 +7523,15 @@ func (r *rpcServer) ListPayments(ctx context.Context,
CreationDateEnd: int64(req.CreationDateEnd),
}
// If the maximum number of payments wasn't specified, then we'll
// default to return the maximal number of payments representable.
// If the maximum number of payments wasn't specified, we default to
// a reasonable number to prevent resource exhaustion. All of the
// payments are fetched into memory. Moreover we don't want our daemon
// to remain stable and do other stuff rather than serving payments.
//
// TODO(ziggie): Choose a more specific default value when results of
// performance testing are available.
if req.MaxPayments == 0 {
query.MaxPayments = math.MaxUint64
query.MaxPayments = paymentsdb.DefaultMaxPayments
}
paymentsQuerySlice, err := r.server.paymentsDB.QueryPayments(