pub trait PoolView:
Send
+ Sync
+ Debug {
// Required method
fn status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn cached_status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn signer_authorization<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
signer: Address,
) -> Pin<Box<dyn Future<Output = Option<SignerAuthorization>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn signer_spent_cached<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
signer: Address,
) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
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.
Required Methods§
Sourcefn status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The pool’s status, or None if the pool cannot be confirmed. The
stream-admission read: a caller here may tolerate a blocking source, so an
implementation MAY do slow work. The bare PoolProjection reads from
memory and returns None for a pool it has not folded; the production
wrapper (crate::payment_settlement::ResolvingPoolView) confirms such a
pool with one getPool before returning, so the admit gate refuses a
pool it still cannot confirm rather than failing open.
Provided Methods§
Sourcefn cached_status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cached_status<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
) -> Pin<Box<dyn Future<Output = Option<PoolStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A read that MUST NOT block: it returns None rather than doing any slow or
remote work. The mid-stream serve re-check calls it at each voucher
boundary, where a blocking read would stall delivery. The default delegates
to Self::status for in-memory test doubles; PoolProjection serves
both from the same in-memory map, so neither ever touches the network.
The admit-path signer confirm: the request’s voucher signer on-chain
authorization in pool_id (ADR 003 §Capability delegation, §Pool
solvency). A signer’s cap is shared across every provider, so a signer
that has drawn its full cap at other nodes is uncashable here. Its
registered cap and expiry are write-once, so they bound every voucher
whatever capability the client presents.
Some(SignerAuthorization::Unregistered)— no on-chain constraint. An unregistered signer (it has spent nothing on-chain, so it admits on its presented capability) or no chain wired.Some(SignerAuthorization::Registered { .. })— the registered terms and the signer’s currentspent.None— the on-chain read faulted and no registered read of this signer is held. The caller refuses it as unconfirmed rather than fail open. An earlierUnregisteredread is not trusted after a fault, because a registration can land at any time.
The default reports every signer unregistered: the bare PoolProjection
and test doubles hold no chain. The production wrapper
(crate::payment_settlement::ResolvingPoolView) overrides it with one
getAuthorization per (pool, signer), held for good once it reads
Registered and with spent brought up to the projection’s fold.
Sourcefn signer_spent_cached<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
signer: Address,
) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn signer_spent_cached<'life0, 'async_trait>(
&'life0 self,
pool_id: B256,
signer: Address,
) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The mid-stream signer-drain read: a signer’s total on-chain spent across
every provider in pool_id, from the event-fed projection ONLY — never a
chain call. The serve loop pairs it with the cap the node already holds on
the lane to test held_cap − spent headroom at the POOL_RECHECK_INTERVAL
cadence, so a signer draining its shared cap at another node mid-stream stops
this stream before it over-delivers unredeemable bytes (ADR 003 §Pool
solvency).
Some(spent)— the folded cross-provider total,0for a signer that has redeemed nothing in a pool the projection knows.None— no projection is wired (a chain-free test double), so the re-check is skipped and delivery continues; the on-chainredeemManymin(desired, cap − spent)remains the backstop.
The default returns None. PoolProjection and the production wrapper
(crate::payment_settlement::ResolvingPoolView) override it to read the
projection, matching how Self::cached_status reads a pool’s remaining
without blocking.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".