You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(aid_escrow): index packages by recipient for O(1) queries (#445)
Maintain a per-recipient secondary index (rcnt counter + rpidx
(recipient, seq) -> package_id entries) written atomically on every
package-creation path, and back get_recipient_package_count and
list_recipient_packages with it instead of a linear scan of the global
package-ID space.
get_recipient_package_count is now O(1), list_recipient_packages pages
over the recipient's own index (contiguous matches, continuation
cursor, no skipped matches for sparse IDs) and clamps limit to a
documented MAX_RECIPIENT_PAGE_SIZE. The index uses instance storage:
persistent writes metered ~3x higher in Soroban SDK 23 and pushed the
200-package batch past the budget, while instance storage keeps it
within limits (see GAS_PROFILING_REPORT.md).
Co-authored-by: Xhr!st!n3 <208627422+Xhristin3@users.noreply.github.com>
Copy file name to clipboardExpand all lines: app/onchain/README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,16 @@ Events use stable topic identifiers (struct name in snake_case) so indexers and
91
91
|`get_package(id)`| Returns full package details | None |
92
92
|`view_package_status(id)`| Returns only the status of a package | None |
93
93
|`get_aggregates(token)`| Returns total committed/claimed/expired stats | None |
94
+
|`get_recipient_package_count(recipient)`| Returns the number of packages for a recipient (O(1), via the recipient index) | None |
95
+
|`list_recipient_packages(recipient, cursor, limit)`| Returns `{ ids, next_cursor }` — a page of recipient package IDs plus the cursor for the next page | None |
96
+
97
+
#### Recipient pagination contract
98
+
99
+
`list_recipient_packages` pages over the recipient's secondary index, so pages contain only that recipient's packages — no skipped matches, no empty pages while matches remain — regardless of how sparse the global package-ID space is.
100
+
101
+
-`cursor` is the per-recipient index ordinal from the previous page's `next_cursor` (`0` for the first page).
102
+
-`limit` is clamped to `MAX_RECIPIENT_PAGE_SIZE = 100`, so a single read call can never request an unbounded scan window.
103
+
-`next_cursor` is the ordinal to pass as the next `cursor`; when it equals the recipient's total count, there are no further pages.
0 commit comments