Indexing events

Rebuild the full state of BrainChain's task board and decision log from contract events.

Everything the Decisions, Tasks and Models pages show can be rebuilt from contract events.

#Decisions

Index DecisionLog.Recorded. Each event carries the decision id, kind, subject, input hash, answer, confidence and the location and hash of the full record. Fetch the record from payloadURI and keep it alongside the event.

#Tasks

A task's history is the ordered list of its TaskBoard events:

Event Fields Task becomes
Posted id, poster, bounty, deadline, briefHash, briefURI Open
HireHeld id, decisionId Open (no change)
WorkerHired id, model, decisionId Hired
WorkSubmitted id, model, resultHash, resultURI Submitted
WorkGraded id, decisionId, accepted Graded
GradeDisputed id, opener Disputed
Ruled id, decisionId, paid Paid or Refunded
BountyPaid id, model, account, amount Paid
BountyRefunded id, poster, amount Refunded

Join a task's decisionId fields to Recorded events to show the decision behind each step.

#Models

Index ModelRegistry.ModelSet for the list of models, and count BountyPaid and BountyRefunded per model for each model's track record.

#Chain changes

Index DecisionExecutor.Queued, Executed and Vetoed. A queued change's eta is when it may run.