Skip to content

Optimize get_top_traders to only fetch requested candidate set - #119

Merged
ameeribro4-sudo merged 1 commit into
OpenPeerX:mainfrom
snowrugar-beep:fix/issue-69-optimize-get-top-traders
Jul 21, 2026
Merged

Optimize get_top_traders to only fetch requested candidate set#119
ameeribro4-sudo merged 1 commit into
OpenPeerX:mainfrom
snowrugar-beep:fix/issue-69-optimize-get-top-traders

Conversation

@snowrugar-beep

Copy link
Copy Markdown
Contributor

Summary

Optimized get_top_traders to only fetch the requested candidate set instead of always fetching 100 entries.

Changes

  • peerx-contracts/counter/src/lib.rs: get_top_traders now fetches max(limit, 100) candidates instead of hardcoded 100; apply_trader_limit no longer caps at 100 (caller controls this)
  • peerx-contracts/counter/portfolio.rs: Removed hard cap of 100 from get_top_traders — the function now iterates exactly up to the requested limit (O(limit) instead of O(100))
  • Net reduction of 9 lines
  • No unrelated changes introduced

Closes #69

@ameeribro4-sudo ameeribro4-sudo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ameeribro4-sudo
ameeribro4-sudo merged commit 822af72 into OpenPeerX:main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PeerX Backlog # 69] Optimize get_top_traders while truncating to limit

2 participants