Skip to content

swap poller: use get_miner_active_swaps over bounded scan#165

Merged
anderdc merged 2 commits into
testfrom
fix/swap-id-from-validator
Apr 23, 2026
Merged

swap poller: use get_miner_active_swaps over bounded scan#165
anderdc merged 2 commits into
testfrom
fix/swap-id-from-validator

Conversation

@LandynDev
Copy link
Copy Markdown
Collaborator

Closes #150.

The old resolve_recent_swap_id scanned a fixed 4-ID window back from next_id-1. Correct diagnosis in #150 (and PR #161), but widening the window to 5/100/N is still guessing.

Swaps it for the existing client.get_miner_active_swaps(hotkey) helper, which uses the standard 50-consecutive-nones scan pattern from contract_client. Also removes a duplicate inline scan in poll_for_swap_with_progress.

Net: -5 lines, no magic number, correct regardless of swap position.

Replaces the hand-rolled 4-ID backward scan in resolve_recent_swap_id
(and its duplicate in poll_for_swap_with_progress) with the existing
get_miner_active_swaps helper. The old bound relied on a guessed
window size; the helper uses the standard 50-consecutive-nones pattern
already used throughout contract_client, so correctness no longer
depends on picking the right magic number.

Closes #150
@LandynDev
Copy link
Copy Markdown
Collaborator Author

@anderdc check this out

@anderdc anderdc merged commit 624ef27 into test Apr 23, 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.

swap: off-by-one in recent swap scan can hide real active swap

2 participants