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

    Interface ReservationStore

    The shared cross-node reservation counter: one pending total per account, folded atomically. add returns the post-add total, so accept screens are add-then-check — a concurrent add on another node is either already in the returned total or arrives later and sees ours; totals only drift conservative (at-or-after our add). Fail-closed by construction: an unreachable counter throws, and the caller refuses the movement rather than accepting blind.

    interface ReservationStore {
        add(
            account: AccountRef,
            naturalDelta: bigint,
            options?: CallOptions,
        ): Promise<bigint>;
        entries(options?: CallOptions): AsyncIterable<[AccountRef, bigint]>;
        pending(account: AccountRef, options?: CallOptions): Promise<bigint>;
    }
    Index
    • Folds naturalDelta — the movement leg's signed effect on the account's balance in minor units (balanceDelta; a spend adds a negative delta) — into the account's pending total and returns the post-add total. Atomic per account: two nodes adding concurrently both see a total that includes at least their own delta.

      Parameters

      Returns Promise<bigint>

    • Streams every counter row — what reconcileReservations (src/worker/orphans.ts) walks to repair leaked pending against the journal-derived truth during quiesced maintenance.

      Parameters

      Returns AsyncIterable<[AccountRef, bigint]>