What changed, and why it matters
This commit simply renames two internal helper functions so they can be used by other parts of the codebase. It does not change what the functions do, how they work, or any user-facing behavior. There is no security issue here.
No action required. This is a benign refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch exports the paginator constructor and query method by capitalizing their names (newPaginator -> NewPaginator, query -> Query) and updates call sites in channeldb/invoices.go and channeldb/payments_kv_store.go. The paginator struct itself remains unexported. No logic, signatures, or behavior changed; this is a pure visibility refactor to allow a future kv store implementation in another package to reuse the pagination logic.
Changed components
channeldb/paginate.gochanneldb/invoices.gochanneldb/payments_kv_store.goInspect captured patch +8 / −8
diff --git a/channeldb/invoices.go b/channeldb/invoices.go
index 161fa4a..ab8d142 100644
--- a/channeldb/invoices.go
+++ b/channeldb/invoices.go
@@ -553,7 +553,7 @@ func (d *DB) QueryInvoices(_ context.Context, q invpkg.InvoiceQuery) (
// Create a paginator which reads from our add index bucket with
// the parameters provided by the invoice query.
- paginator := newPaginator(
+ paginator := NewPaginator(
invoiceAddIndex.ReadCursor(), q.Reversed, q.IndexOffset,
q.NumMaxInvoices,
)
@@ -603,7 +603,7 @@ func (d *DB) QueryInvoices(_ context.Context, q invpkg.InvoiceQuery) (
// Query our paginator using accumulateInvoices to build up a
// set of invoices.
- if err := paginator.query(accumulateInvoices); err != nil {
+ if err := paginator.Query(accumulateInvoices); err != nil {
return err
}
diff --git a/channeldb/paginate.go b/channeldb/paginate.go
index 496c236..dbb3548 100644
--- a/channeldb/paginate.go
+++ b/channeldb/paginate.go
@@ -16,9 +16,9 @@ type paginator struct {
totalItems uint64
}
-// newPaginator returns a struct which can be used to query an indexed bucket
+// NewPaginator returns a struct which can be used to query an indexed bucket
// in pages.
-func newPaginator(c kvdb.RCursor, reversed bool,
+func NewPaginator(c kvdb.RCursor, reversed bool,
indexOffset, totalItems uint64) paginator {
return paginator{
@@ -105,14 +105,14 @@ func (p paginator) cursorStart() ([]byte, []byte) {
return indexKey, indexValue
}
-// query gets the start point for our index offset and iterates through keys
+// Query gets the start point for our index offset and iterates through keys
// in our index until we reach the total number of items required for the query
// or we run out of cursor values. This function takes a fetchAndAppend function
// which is responsible for looking up the entry at that index, adding the entry
// to its set of return items (if desired) and return a boolean which indicates
// whether the item was added. This is required to allow the paginator to
// determine when the response has the maximum number of required items.
-func (p paginator) query(fetchAndAppend func(k, v []byte) (bool, error)) error {
+func (p paginator) Query(fetchAndAppend func(k, v []byte) (bool, error)) error {
indexKey, indexValue := p.cursorStart()
var totalItems int
diff --git a/channeldb/payments_kv_store.go b/channeldb/payments_kv_store.go
index cf2ca91..d18616c 100644
--- a/channeldb/payments_kv_store.go
+++ b/channeldb/payments_kv_store.go
@@ -1205,13 +1205,13 @@ func (p *KVPaymentsDB) QueryPayments(_ context.Context,
// Create a paginator which reads from our sequence index bucket
// with the parameters provided by the payments query.
- paginator := newPaginator(
+ paginator := NewPaginator(
indexes.ReadCursor(), query.Reversed, query.IndexOffset,
query.MaxPayments,
)
// Run a paginated query, adding payments to our response.
- if err := paginator.query(accumulatePayments); err != nil {
+ if err := paginator.Query(accumulatePayments); err != nil {
return err
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.