@pwngh/economy-lab
    Preparing search index...

    Interface Worker

    Handle the host program uses to drive the background jobs: one-shot passes via Worker.sweep, a timer loop via Worker.start, and a maintenance gate via pause/resume.

    interface Worker {
        sweepsPaused: boolean;
        pause(): void;
        resume(): void;
        start(everyMs: number, request?: Omit<SweepRequest, "now">): () => void;
        sweep(request?: SweepRequest): Promise<SweepRun>;
    }
    Index
    sweepsPaused: boolean

    The pause gate's state, named apart from the economy's own maintenanceActive.

    • Makes the scheduled runs no-ops until Worker.resume; the timer keeps ticking, so stopping stays with whoever holds the stop function.

      Returns void

    • Runs the jobs every everyMs on a timer — the Scheduler port when the bag has one, a built-in interval timer otherwise — and returns a stop function. Every tick reads now from the clock, which is why its request cannot carry one.

      Parameters

      Returns () => void

    • Runs every job once at one resolved tick and returns the batch plus the txn id of every posting the run minted. Each job runs isolated, so one throw becomes that job's failed result and the rest still run; sweep itself never throws. An explicit sweep still runs while paused — a supervisor or operator acting deliberately is not the loop being paused.

      Parameters

      Returns Promise<SweepRun>