mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-05 20:49:48 +02:00
channeldb: eliminate extra copy in QueryPayments
In this commit, we eliminate an extraneous copy in the `QueryPayments` method. Before this commit, we would copy each payment from the initial FetchPayments call into a new slice. However, pointers to payments are return from `FetchPayments`, so we can just maintain that same reference rather than copying again when we want to limit our response.
This commit is contained in:
parent
315c56607c
commit
cc1dbb5677
@ -460,7 +460,7 @@ type PaymentsQuery struct {
|
|||||||
type PaymentsResponse struct {
|
type PaymentsResponse struct {
|
||||||
// Payments is the set of payments returned from the database for the
|
// Payments is the set of payments returned from the database for the
|
||||||
// PaymentsQuery.
|
// PaymentsQuery.
|
||||||
Payments []MPPayment
|
Payments []*MPPayment
|
||||||
|
|
||||||
// FirstIndexOffset is the index of the first element in the set of
|
// FirstIndexOffset is the index of the first element in the set of
|
||||||
// returned MPPayments. Callers can use this to resume their query
|
// returned MPPayments. Callers can use this to resume their query
|
||||||
@ -536,7 +536,7 @@ func (db *DB) QueryPayments(query PaymentsQuery) (PaymentsResponse, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Payments = append(resp.Payments, *payment)
|
resp.Payments = append(resp.Payments, payment)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to swap the payments slice order if reversed order.
|
// Need to swap the payments slice order if reversed order.
|
||||||
|
@ -5191,7 +5191,7 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
|||||||
for _, payment := range paymentsQuerySlice.Payments {
|
for _, payment := range paymentsQuerySlice.Payments {
|
||||||
payment := payment
|
payment := payment
|
||||||
|
|
||||||
rpcPayment, err := r.routerBackend.MarshallPayment(&payment)
|
rpcPayment, err := r.routerBackend.MarshallPayment(payment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user