File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11package paymentsdb
22
3+ const (
4+ // DefaultMaxPayments is the default maximum number of payments returned
5+ // in the payments query pagination.
6+ DefaultMaxPayments = 100
7+ )
8+
39// Query represents a query to the payments database starting or ending
410// at a certain offset index. The number of retrieved records can be limited.
511type Query struct {
Original file line number Diff line number Diff line change @@ -7523,10 +7523,15 @@ func (r *rpcServer) ListPayments(ctx context.Context,
75237523 CreationDateEnd : int64 (req .CreationDateEnd ),
75247524 }
75257525
7526- // If the maximum number of payments wasn't specified, then we'll
7527- // default to return the maximal number of payments representable.
7526+ // If the maximum number of payments wasn't specified, we default to
7527+ // a reasonable number to prevent resource exhaustion. All of the
7528+ // payments are fetched into memory. Moreover we don't want our daemon
7529+ // to remain stable and do other stuff rather than serving payments.
7530+ //
7531+ // TODO(ziggie): Choose a more specific default value when results of
7532+ // performance testing are available.
75287533 if req .MaxPayments == 0 {
7529- query .MaxPayments = math . MaxUint64
7534+ query .MaxPayments = paymentsdb . DefaultMaxPayments
75307535 }
75317536
75327537 paymentsQuerySlice , err := r .server .paymentsDB .QueryPayments (
You can’t perform that action at this time.
0 commit comments