Skip to content

Predictions confirmation worker driven by indexer events #88

Description

@greatest0fallt1me

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

  1. Fork the repo and create a branch
    git checkout -b feature/predictions-confirmer
  2. Implement changes
    • src/workers/predictionsConfirmer.ts
    • Extend predictions with confirmAttempts, lastError
    • Wire webhook emission
  3. 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

  • Batch tick processes 1000 rows in < 500ms
  • Failed rows do not block siblings
  • Webhook emitted exactly once per confirmation

Guidelines

  • Use FOR UPDATE SKIP LOCKED to allow safe horizontal scaling
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Labels

GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programbackendBackend service work
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions