Description
After the indexer ingests a bet_placed event, the corresponding pending row in predictions must transition to confirmed. Add a worker that joins indexer_events against predictions on txHash and advances state, emitting a webhook event.
Requirements and Context
src/workers/predictionsConfirmer.ts runs every PREDICTION_CONFIRM_INTERVAL_MS
- Batches updates in a single transaction per tick
- Emits
prediction.confirmed to the webhook dispatcher
- Stops processing a row after 3 failed attempts and records
lastError
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feature/predictions-confirmer
- Implement changes
src/workers/predictionsConfirmer.ts
- Extend
predictions with confirmAttempts, lastError
- Wire webhook emission
- Test and commit
- Insert event + matching prediction → assert transition
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: pending-to-confirmed predictions worker
Acceptance Criteria
Guidelines
- Use
FOR UPDATE SKIP LOCKED to allow safe horizontal scaling
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
After the indexer ingests a
bet_placedevent, the corresponding pending row inpredictionsmust transition toconfirmed. Add a worker that joinsindexer_eventsagainstpredictionsontxHashand advances state, emitting a webhook event.Requirements and Context
src/workers/predictionsConfirmer.tsruns everyPREDICTION_CONFIRM_INTERVAL_MSprediction.confirmedto the webhook dispatcherlastErrorSuggested Execution
src/workers/predictionsConfirmer.tspredictionswithconfirmAttempts,lastErrorExample commit message
Acceptance Criteria
Guidelines
FOR UPDATE SKIP LOCKEDto allow safe horizontal scaling