Commit d5eec9e
fix: prevent race condition in bounty claim with atomic status check (#24)
The bounty claim handler uses a SELECT to check status, then a separate
UPDATE to set it. Two concurrent requests can both pass the status check
and claim the same bounty, potentially triggering duplicate payouts.
Add a WHERE status IN ('open', 'funded') clause to the UPDATE so only
the first concurrent claim succeeds at the database level, and verify
the claimer_did after the UPDATE to detect and reject losing races.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b93d28c commit d5eec9e
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
0 commit comments