channeldb: add a paginator struct to process generic pagination
We now use the same method of pagination for invoices and payments. Rather than duplicate logic across calls, we add a pagnator struct which can have query specific logic plugged into it. This commit also addresses an existing issue where a reverse query for invoices with an offset larger than our last offset would not return any invoices. We update this behaviour to act more like c.Seek and just start from the last entry. This behaviour change is covered by a unit test that previously checked for the lack of invoices.
This commit is contained in:
3 files changed
+169
-67
No files matched your search
@@ -1008,8 +1008,8 @@ func TestQueryInvoices(t *testing.T) {
|
||||
expected: pendingInvoices[len(pendingInvoices)-15:],
|
||||
},
|
||||
// Fetch all invoices paginating backwards, with an index offset
|
||||
// that is beyond our last offset. We currently do not return
|
||||
// anything if our index is greater than our last index.
|
||||
// that is beyond our last offset. We expect all invoices to be
|
||||
// returned.
|
||||
{
|
||||
query: InvoiceQuery{
|
||||
IndexOffset: numInvoices * 2,
|
||||
@@ -1017,7 +1017,7 @@ func TestQueryInvoices(t *testing.T) {
|
||||
Reversed: true,
|
||||
NumMaxInvoices: numInvoices,
|
||||
},
|
||||
expected: nil,
|
||||
expected: invoices,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user