Skip to content

refactor: batch persistent storage reads into context structs#150

Merged
shakurJJ merged 2 commits into
shakurJJ:mainfrom
MooreTheAnalyst:refactor/batch-storage-reads
Jun 26, 2026
Merged

refactor: batch persistent storage reads into context structs#150
shakurJJ merged 2 commits into
shakurJJ:mainfrom
MooreTheAnalyst:refactor/batch-storage-reads

Conversation

@MooreTheAnalyst

Copy link
Copy Markdown
Contributor

Batch Persistent Storage Reads
Consolidates multiple sequential storage reads into typed context structs for three key functions, reducing storage operation overhead.

Changes
CreateShipmentCtx: Groups validation reads (MaxShipmentValue, AllowedTokens, MinMilestonePercent, ContractStats) into single helper fetch
ConfirmMilestoneCtx: Batches Shipment and ContractStats reads via fetch_confirm_milestone_ctx
ResolveDisputeCtx: Consolidates Shipment, DisputeContestedPercent, ContractStats, and ActiveDisputes into one context fetch
Each helper documents accessed keys as inline comments for future layout optimization.

Result
All three functions now perform a single batched read operation instead of multiple sequential gets, improving storage efficiency while maintaining identical behavior. Lib compiles without errors.

Closes #139

MooreTheAnalyst and others added 2 commits June 25, 2026 22:50
- Add CreateShipmentCtx, ConfirmMilestoneCtx, and ResolveDisputeCtx structs
- Implement helper functions to fetch and populate context structs with all related storage keys
- Refactor create_shipment to use fetch_create_shipment_ctx for batch reads
- Refactor confirm_milestone to use fetch_confirm_milestone_ctx for batch reads
- Refactor resolve_dispute to use fetch_resolve_dispute_ctx for batch reads
- Add inline documentation for each context struct listing all accessed keys
- Fix missing contracterror import

Acceptance criteria met:
- create_shipment reads consolidated into CreateShipmentCtx helper
- confirm_milestone reads consolidated into ConfirmMilestoneCtx helper
- resolve_dispute reads consolidated into ResolveDisputeCtx helper
- Context helpers document their key access list in comments
- Lib compiles without errors
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@MooreTheAnalyst 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! 🚀

Learn more about application limits

@shakurJJ
shakurJJ merged commit 04ef3d5 into shakurJJ:main Jun 26, 2026
1 of 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.

refactor: batch persistent storage reads where multiple keys accessed together

2 participants