Skip to content

refactor(task-registry): replace sponsors Vec with per-address persis… - #14

Merged
cybermax4200 merged 1 commit into
ecotask-network:mainfrom
devOgazi:refactor/sponsor-set-storage
Jul 13, 2026
Merged

refactor(task-registry): replace sponsors Vec with per-address persis…#14
cybermax4200 merged 1 commit into
ecotask-network:mainfrom
devOgazi:refactor/sponsor-set-storage

Conversation

@devOgazi

Copy link
Copy Markdown
Contributor

Summary

Replace the O(n) linear-scan sponsor list (Vec<Address> under DataKey::Sponsors) with a Set-style pattern using per-address boolean flags (DataKey::Sponsor(Address)).

Changes

  • add_sponsor: set(Sponsor(addr), true) instead of Vec push + rewrite entire vector
  • remove_sponsor: remove(Sponsor(addr)) instead of filter-cloning the entire Vec
  • is_sponsor: has(Sponsor(addr)) instead of Vec::contains linear scan
  • Switched from instance() to persistent() storage so sponsor status survives the instance TTL (~100 ledgers), matching durability of tasks and completions

Performance Impact

Operation Before After
is_sponsor O(n) scan O(1) lookup
add_sponsor O(1) amortized (but re-serializes full Vec) O(1) single key write
remove_sponsor O(n) scan + clone O(1) single key delete

Testing

All 38 tests pass (18 task-registry + 20 reward-engine). Test snapshots updated to reflect new storage layout.

Closes #4

@devOgazi
devOgazi force-pushed the refactor/sponsor-set-storage branch from cb27e06 to 56af28a Compare July 13, 2026 12:11
…tent storage

Replace the O(n) linear-scan sponsor list (Vec<Address> under DataKey::Sponsors)
with a Set-style pattern using per-address boolean flags (DataKey::Sponsor(Address)).

- add_sponsor: set(Sponsor(addr), true) instead of Vec push + rewrite
- remove_sponsor: remove(Sponsor(addr)) instead of filter-clone entire Vec
- is_sponsor: has(Sponsor(addr)) instead of Vec::contains scan
- Switched from instance() to persistent() storage for sponsor durability
- Added **/test_snapshots/ to .gitignore to prevent merge conflicts
@devOgazi
devOgazi force-pushed the refactor/sponsor-set-storage branch from 56af28a to 9cc09d2 Compare July 13, 2026 12:14
@cybermax4200
cybermax4200 merged commit dfd668f into ecotask-network:main Jul 13, 2026
2 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.

task-registry: Sponsor list uses linear scan — replace with a Set-style storage pattern

2 participants