Skip to main content

PoolOpener

Trait PoolOpener 

Source
pub trait PoolOpener:
    Send
    + Sync
    + Debug {
    // Required methods
    fn open_or_reuse_pool<'life0, 'async_trait>(
        &'life0 self,
        provider_addr: Address,
        budget: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<PoolContext>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_progress(
        &self,
        provider_addr: Address,
        pool_id: PoolId,
        write: ProgressWrite,
    ) -> Result<()>;

    // Provided methods
    fn recover_pool<'life0, 'async_trait>(
        &'life0 self,
        _seen_deposit: U256,
    ) -> Pin<Box<dyn Future<Output = Result<Recovery>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn pool_deposit(&self) -> Option<U256> { ... }
}
Expand description

Object-safe seam over BuyerPoolService (#831).

BuyerPoolService is generic over the alloy Provider, but the node-to-node pull origin (crate::node_origin::NodeOrigin) is stored as an Arc<dyn Origin> and cannot itself be generic. This trait erases the provider type so the origin holds the bootstrapped service behind an Arc<dyn PoolOpener> and opens (or reuses) the node’s buyer pool on a cache-miss pull.

Required Methods§

Source

fn open_or_reuse_pool<'life0, 'async_trait>( &'life0 self, provider_addr: Address, budget: Duration, ) -> Pin<Box<dyn Future<Output = Result<PoolContext>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Open or reuse the node’s buyer pool and return a PoolContext pinned to provider_addr (with the self-issued capability attached). See BuyerPoolService::open_or_reuse_pool for the full contract.

Source

fn record_progress( &self, provider_addr: Address, pool_id: PoolId, write: ProgressWrite, ) -> Result<()>

Persist one lane’s voucher progress on the (signer, provider) lane of pool_id. See BuyerPoolService::record_progress.

§Errors

On store write failure.

Provided Methods§

Source

fn recover_pool<'life0, 'async_trait>( &'life0 self, _seen_deposit: U256, ) -> Pin<Box<dyn Future<Output = Result<Recovery>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the node’s funding recovery step on its buyer pool, for a fill that saw seen_deposit. See BuyerPoolService::recover_pool.

Defaults to “funding not supported”, so a read-only or test double need not override it: Recovery::Unavailable.

§Errors

Implementations error when no pool is tracked, when the allowance, topUp or replacement openPool fails, or when a transaction lands but the local row can no longer record it.

Source

fn pool_deposit(&self) -> Option<U256>

The deposit the node’s pool row records now, or None with no pool tracked. See BuyerPoolService::pool_deposit.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§