Skip to main content

Module pool_view

Module pool_view 

Source
Expand description

Event-fed on-chain pool view for the serve path (ADR 003 §Sizing).

The cdn/client/v1 serve handler holds no RPC client, but two of its gates need a pool-level chain quantity per request:

  • Floor-M solvency — the pool’s remaining balance (getPool.deposit − getPool.totalRedeemed) minus the refundable floor M must still cover the credit window, or the node refuses Unfunded before signing ok: true.
  • ADR 011 funder gate — the pool owner (getPool.owner) is the funding address the origin-blacklist gate evaluates, at open time and mid-stream.

Both quantities are fully determined by the PaymentPool event log, so the serve path reads them from an in-memory projection the settlement watcher folds from that log (crate::payment_settlement) — the common case costs no getPool eth_call. The two reads split by whether the caller can block:

  • Admission (PoolView::status) MAY block. The production wrapper (crate::payment_settlement::ResolvingPoolView) reads the projection first and, on a miss (a pool opened before the watcher’s cold-start head), does ONE getPool to confirm the pool exists and is solvent BEFORE a serve is admitted. An absent, closed, or errored pool yields None and the admit gate refuses — it does not fail open.
  • Mid-stream (PoolView::cached_status) MUST NOT block: it reads the projection only. An admitted stream’s pool was seeded at admission and a projection entry persists until the pool is forgotten (a PoolReclaimed removes it), so a None here is not expected for a live stream; if it does occur it fails open, since the on-chain redeem is the backstop and a chain read at a voucher boundary would stall delivery.

The bare PoolProjection is the projection itself: its status returns None for a pool it has not folded and never touches the network. Tests wire it (or a fake) directly; production wraps it in the getPool-on-miss view.

Structs§

PoolProjection
An event-fed PoolView: the serve gates read {owner, remaining} from an in-memory projection the settlement watcher folds from the PaymentPool event log, so no serve request costs a getPool eth_call.
PoolStatus
The per-pool chain quantities the serve gates read.

Enums§

Lifecycle
A pool’s on-chain lifecycle, folded from the PaymentPool event log. Open pools accept top-ups and redemptions; a Closing pool accepts redemptions only until deadline (the on-chain dispute deadline), after which redeemMany reverts PoolClosed. A pool never returns to Open once Closing, and a Closing pool cannot be topped up, so its remaining only falls.

Constants§

POOL_RECHECK_INTERVAL
Wall-clock cadence for the serve loops’ mid-stream pool-solvency re-check (ADR 003 §Pool solvency policy).

Traits§

PoolView
A per-request source of PoolStatus. Trait so the handler holds it behind an Arc<dyn PoolView> and tests pass a fake (or None) without a chain.