From fc41ecc74092e8218c9371db0693df596f488146 Mon Sep 17 00:00:00 2001 From: MPins Date: Mon, 1 Jul 2024 14:49:59 -0300 Subject: [PATCH] channeldb: Fixes the count of payments returned by QueryPayments QueryPayments function was changed to return the toyal num of payments considering the date start and date end restrictions existing on the query --- channeldb/payments.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/channeldb/payments.go b/channeldb/payments.go index a1baa07f7a2..cd6d606cf62 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -597,28 +597,7 @@ func (d *DB) QueryPayments(query PaymentsQuery) (PaymentsResponse, error) { // literally have to traverse the cursor linearly, which can // take quite a while. So it's an optional query parameter. if query.CountTotal { - var ( - totalPayments uint64 - err error - ) - countFn := func(_, _ []byte) error { - totalPayments++ - - return nil - } - - // In non-boltdb database backends, there's a faster - // ForAll query that allows for batch fetching items. - if fastBucket, ok := indexes.(kvdb.ExtendedRBucket); ok { - err = fastBucket.ForAll(countFn) - } else { - err = indexes.ForEach(countFn) - } - if err != nil { - return fmt.Errorf("error counting payments: %w", - err) - } - + totalPayments := uint64(len(resp.Payments)) resp.TotalCount = totalPayments }