Description
The logic get_tally(e, market_id, u32::MAX) is used as a heuristic for tracking Cancel votes. Using u32::MAX as a reserved index is undocumented and risk-prone if a market were to theoretically support a very large number of legitimate outcomes. It lacks type safety and clear intention.
Requirements and context
- Define a formal constant or enum variant for the cancellation vote index.
- Centralize the definition in
types.rs.
Suggested execution
- Fork the repo and create a branch:
git checkout -b refactor/issue-54-cancel-index
- Replace raw literal with named constant.
Implementation changes
- Add
pub const CANCEL_OUTCOME_INDEX: u32 = u32::MAX; to types.rs.
- Update
cancellation.rs and voting.rs to use this constant.
Test and commit
- Verify that votes cast for the
CANCEL_OUTCOME_INDEX are correctly aggregated.
Example commit message
refactor: define and use CANCEL_OUTCOME_INDEX constant instead of raw literal
Guidelines
- Code maintainability.
- Timeframe: 12 hours.
Description
The logic
get_tally(e, market_id, u32::MAX)is used as a heuristic for tracking Cancel votes. Usingu32::MAXas a reserved index is undocumented and risk-prone if a market were to theoretically support a very large number of legitimate outcomes. It lacks type safety and clear intention.Requirements and context
types.rs.Suggested execution
git checkout -b refactor/issue-54-cancel-indexImplementation changes
pub const CANCEL_OUTCOME_INDEX: u32 = u32::MAX;totypes.rs.cancellation.rsandvoting.rsto use this constant.Test and commit
CANCEL_OUTCOME_INDEXare correctly aggregated.Example commit message
refactor: define and use CANCEL_OUTCOME_INDEX constant instead of raw literal
Guidelines