pub struct PoolSettlementService<P: Provider + Clone + 'static> { /* private fields */ }Expand description
Seller-side PaymentPool settlement service. Generic over the alloy
Provider (a wallet-filled provider is required for the redeem /
redeemMany write path). Cheap to construct; owns its background tasks.
Implementations§
Source§impl<P: Provider + Clone + 'static> PoolSettlementService<P>
impl<P: Provider + Clone + 'static> PoolSettlementService<P>
Sourcepub async fn bootstrap(
provider: P,
payment_pool_addr: Address,
self_address: Address,
store: Arc<dyn PoolStateStore>,
checkpoint_store: Arc<dyn KeyedCheckpointStore>,
handler: Arc<ClientHandler>,
redeem_threshold: U256,
redeem_max_vouchers_per_tx: usize,
redeem_interval: Duration,
metrics: Arc<Metrics>,
boot: &BootRetry,
pool_view: PoolProjection,
redeem_tx: Sender<LaneKey>,
redeem_rx: Receiver<LaneKey>,
) -> Result<(Self, Route)>
pub async fn bootstrap( provider: P, payment_pool_addr: Address, self_address: Address, store: Arc<dyn PoolStateStore>, checkpoint_store: Arc<dyn KeyedCheckpointStore>, handler: Arc<ClientHandler>, redeem_threshold: U256, redeem_max_vouchers_per_tx: usize, redeem_interval: Duration, metrics: Arc<Metrics>, boot: &BootRetry, pool_view: PoolProjection, redeem_tx: Sender<LaneKey>, redeem_rx: Receiver<LaneKey>, ) -> Result<(Self, Route)>
Bootstrap the service: self-check the contract, spawn the redemption
task, and return the service alongside the paid-watermark Route the
runtime registers on the shared multiplexed poller.
§Errors
Returns an error if the usdc() self-check fails deterministically — a
bad payment_pool_address is fatal at bring-up — or if boot’s budget
runs out on transient RPC failures.
Sourcepub fn redeem_hint_sender(&self) -> Sender<LaneKey>
pub fn redeem_hint_sender(&self) -> Sender<LaneKey>
Sender the voucher-accept path uses to hint that a lane’s accrued claim may be ready to plan into a chunk whose aggregate clears the redemption floor. Cloneable; dropping all senders simply ends the redemption task cleanly.
Sourcepub async fn shutdown(&self, deadline: Duration)
pub async fn shutdown(&self, deadline: Duration)
Graceful shutdown: quiesce the redeemer, then run one final best-effort
redeem sweep bounded by deadline so a lane whose chunk has cleared the
floor is not left un-redeemed across the stop. A pool is owner-closed only,
so there is nothing to close here — only redeem.
The paid-watermark watcher is now the shared multiplexed poller’s route,
not a service-owned task: the runtime cancels the poller (which triggers an
async, best-effort flush of this route’s PoolOpened scan checkpoint via
CursorStart::flush) before calling this, but only cancels the token — it
does not await the poller’s exit — so that flush is not guaranteed to
complete before the final sweep below runs. This is fine: the scan
checkpoint is independent of the lane-state redeem sweep and idempotent to
re-scan, so the two can race without a correctness impact.
Trait Implementations§
Auto Trait Implementations§
impl<P> !Freeze for PoolSettlementService<P>
impl<P> !RefUnwindSafe for PoolSettlementService<P>
impl<P> !UnwindSafe for PoolSettlementService<P>
impl<P> Send for PoolSettlementService<P>where
PaymentPoolInstance<P>: Send,
impl<P> Sync for PoolSettlementService<P>where
PaymentPoolInstance<P>: Sync,
impl<P> Unpin for PoolSettlementService<P>where
PaymentPoolInstance<P>: Unpin,
impl<P> UnsafeUnpin for PoolSettlementService<P>where
PaymentPoolInstance<P>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request