Worker
startWorker options, the handle it returns, and what a worker does on every tick.
import { startWorker } from 'arkiv-triggers/worker'
const worker = await startWorker(options)Options
Prop
Type
Handle
| Member | What it is |
|---|---|
address | The worker's address |
sealKey | Its public sealing key (also in its heartbeat) |
stats() | { rules, fired, failed, skipped, lastBlock, heartbeat } |
tick() | Run one pass now (tests) |
stop() | Finish actions in flight, stop the loop, close the feed |
What it does
On start: resume from the lastblock in its previous heartbeat, replay deletes it missed, write a
heartbeat, open the event feed. Then, every pollMs:
- Reload rules if the feed saw a change and
reloadMshas passed (or every2 × reloadMsregardless). - Compute each open rule's deadline (expire targets are re-read every 10 minutes, every 30 seconds within 10 minutes of the deadline, and always right before firing).
- Claim rules due within 8 blocks, settle the claim race, and fire those it won with at least 18 blocks of lease left.
- Write receipts, first in the next transaction.
The heartbeat is renewed every heartbeatMs. See Workers and claims.