π Description
settlement_count_by_status(status) gives a full-history count filtered by lifecycle state without pagination, but there is no equivalent for filtering by anchor β a caller who only wants "how many settlements has this anchor ever opened" must page through list_settlements_by_anchor accumulating a Vec just to measure its length, which is both more expensive and more awkward than a direct count.
π§© Requirements and context
- Add
anchor_settlement_count(env, anchor) -> u64 scanning the full settlement history (same loop shape as settlement_count_by_status) and counting matches on anchor instead of status.
- Document the O(n) scan cost consistent with the other full-history aggregate functions.
- Add regression tests with settlements from multiple anchors interleaved.
π οΈ Suggested execution
- Add the entrypoint to
src/lib.rs beside settlement_count_by_status.
- Add
src/test.rs coverage for an anchor with zero, one, and many settlements, interleaved with other anchors' settlements.
- Add the new view to the README settlement table.
β
Acceptance criteria
π Security notes
A dedicated count avoids callers building an unbounded Vec client-side just to measure activity volume, keeping per-call instruction cost predictable for dashboards that poll many anchors.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
settlement_count_by_status(status)gives a full-history count filtered by lifecycle state without pagination, but there is no equivalent for filtering by anchor β a caller who only wants "how many settlements has this anchor ever opened" must page throughlist_settlements_by_anchoraccumulating aVecjust to measure its length, which is both more expensive and more awkward than a direct count.π§© Requirements and context
anchor_settlement_count(env, anchor) -> u64scanning the full settlement history (same loop shape assettlement_count_by_status) and counting matches onanchorinstead ofstatus.π οΈ Suggested execution
src/lib.rsbesidesettlement_count_by_status.src/test.rscoverage for an anchor with zero, one, and many settlements, interleaved with other anchors' settlements.β Acceptance criteria
anchor_settlement_count(anchor)equals the number of settlements ever opened by that anchor, regardless of status.0for an anchor that has never opened a settlement.list_settlements_by_anchorbehavior is unchanged.π Security notes
A dedicated count avoids callers building an unbounded
Vecclient-side just to measure activity volume, keeping per-call instruction cost predictable for dashboards that poll many anchors.π Guidelines