fix(hunty-core): remove O(n) scan in add_player_to_list on progress save - #1189
Merged
Samuel1-ona merged 1 commit intoSep 30, 2026
Merged
Conversation
Samuel1-ona
pushed a commit
that referenced
this pull request
Oct 2, 2026
- hunty-core: restore `list_clues_for_hunt`, which PR #1189 accidentally replaced with a half-written stub, leaving storage.rs unparsable. - hunty-core: wire the documented `MIN_INVITE_CODE_LENGTH` into `generate_invite_code` and stop ignoring `add_co_creator`'s Result. - reward-manager: thread the explicit `caller` argument the #1061 refactor added to `distribute_rewards` through `distribute_rewards_legacy` and `distribute_proportional`, and update the affected test call sites. - Reformat the workspace with rustfmt; refresh docs/contract-api.md and docs/STORAGE_KEYS.md. - CI: opt the wasm build steps into the Stellar spec-shaking build system required by soroban-sdk 28. - npm audit fix for the ip-address advisory. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1049
Problem
save_player_progressruns on every answer, hint and claim and callsadd_player_to_list. When the player's existence marker was present, thefunction looped over indices
0..countreading each entry until it found theplayer. Every submission therefore cost O(players) storage reads, making large
hunts effectively unplayable.
Fix
add_player_to_listnow trusts the existence marker: if it is set, thefunction returns immediately. No scan.
storage.rs~L1456-1483).is an accurate signal of membership.
Benchmark
Added
bench_save_progress_500_playersintest.rs. It registers 500 players,then measures the CPU instruction cost of a single progress save for the
last-registered player (worst case for the old implementation) and asserts it
stays under a fixed ceiling.
Testing
cargo test -p hunty-corepassescargo fmt/cargo clippycleanAcceptance criteria