pub struct VoucherProgress { /* private fields */ }Expand description
The lane’s committed voucher watermark, returned by [UpstreamPull::finish] /
[UpstreamPull::abort] / [UpstreamPull::progress] and threaded through the
test-util stream_fetch_tracked wrapper as an out-param, so the caller can
persist what it paid (#852).
A pull runs through a PoolLedger seeded from the lane’s prior cumulative
state; this watermark is that ledger read back
(VoucherProgress::from_ledger) — so it
always holds the absolute cumulative totals of the last presumed-accepted
voucher (not per-stream deltas), exactly the (bytes_delivered, amount) pair
the buyer-pool lane record expects. Because the
copy-back runs on every return path (including the Err/timeout arms), the
latest totals survive a mid-stream failure or a paid-but-corrupt delivery.
Implicit acceptance. The watermark tracks vouchers the upstream is
presumed to have accepted — continued delivery is acceptance (ADR 005), so a
sent voucher advances it and only an explicit VoucherRejected rewinds it.
Read the persistable totals via VoucherProgress::advanced, which yields
None when nothing was paid on this stream (so there is nothing to persist).
Implementations§
Source§impl VoucherProgress
impl VoucherProgress
Sourcepub fn from_cumulative(cum: Cumulative, prior_amount: U256) -> Self
pub fn from_cumulative(cum: Cumulative, prior_amount: U256) -> Self
Build the watermark from a ledger Cumulative plus the lane’s seed
amount. advanced is set when the cumulative amount rose past the seed,
preserving the “something was paid iff the watermark advanced” contract
even when the ledger was shared across concurrent streams.
Public because a caller that owns its ledger persists from it directly
rather than through the &mut VoucherProgress out-param — including from a
Drop, where nothing can be awaited and PoolLedger::committed is the
only readable source (#1145 review).
Sourcepub const fn with_rebase_anchor(self, anchor: Option<Cumulative>) -> Self
pub const fn with_rebase_anchor(self, anchor: Option<Cumulative>) -> Self
Attach the watermark the ledger rebased DOWN to and has not persisted
yet (PoolLedger::take_unsaved_rebase).
Sourcepub const fn rebase_anchor(&self) -> Option<Cumulative>
pub const fn rebase_anchor(&self) -> Option<Cumulative>
The watermark to overwrite the lane record with before advancing, when the ledger rebased down to the node’s and no persist has recorded it yet. A monotone advance refuses a lower watermark, so without the overwrite the next run would sign from the anchor the node refused.
Sourcepub fn from_ledger(ledger: &PoolLedger, prior_amount: U256) -> Self
pub fn from_ledger(ledger: &PoolLedger, prior_amount: U256) -> Self
The same watermark, read from a live ledger.
Prefer this wherever a ledger is in hand: it reads
PoolLedger::settlement rather than a copied-back cumulative, so a
voucher left armed by an ambiguous send is still reported as owed.
It also TAKES the ledger’s unsaved rebase anchor, so call it only where the result is persisted: the anchor is handed out once.
Trait Implementations§
Source§impl Clone for VoucherProgress
impl Clone for VoucherProgress
impl Copy for VoucherProgress
Source§impl Debug for VoucherProgress
impl Debug for VoucherProgress
Auto Trait Implementations§
impl Freeze for VoucherProgress
impl RefUnwindSafe for VoucherProgress
impl Send for VoucherProgress
impl Sync for VoucherProgress
impl Unpin for VoucherProgress
impl UnsafeUnpin for VoucherProgress
impl UnwindSafe for VoucherProgress
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more