feat: Add get_streams_by_sender with paginated index - #911
feat: Add get_streams_by_sender with paginated index#911Miraclechukwuemeka wants to merge 1 commit into
Conversation
Add a SenderStreams(Address) ledger key index that maintains a Vec<u64> of stream IDs per sender in creation order. The new get_streams_by_sender(sender, page, page_size) query function returns a paginated slice (max 100 per page), enabling efficient lookups for senders with 100+ streams without scanning all storage. Index is maintained on both create_stream and create_split_stream (including parent + children). Empty vec returned for unknown senders. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@Miraclechukwuemeka is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Miraclechukwuemeka Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Closes #686
Adds
get_streams_by_sender(sender: Address, page: u32, page_size: u32) -> Vec<u64>to the Soroban smart contract, enabling paginated queries for all streams created by a given sender.Changes
contracts/src/lib.rs:SenderStreams(Address)variant toDataKeyenum for the ledger indexcreate_streamto maintain the sender streams index on stream creationcreate_split_streamto maintain the index (parent + all children)get_streams_by_senderfunction with:page,page_size)Vec<u64>of stream IDs in creation ordercontracts/src/test.rs— 6 new tests:test_get_streams_by_sender_returns_all_stream_ids— verifies IDs returned in creation ordertest_get_streams_by_sender_empty_for_unknown_sender— empty vec for unknown sendertest_get_streams_by_sender_pagination— correct slicing across 5 streams with page_size=2test_get_streams_by_sender_includes_split_stream_children— split streams index parent + childrentest_get_streams_by_sender_does_not_mix_senders— sender isolationtest_get_streams_by_sender_page_size_clamped_to_100— oversized page_size is clampedAcceptance Criteria