Skip to main content

MemoryPoolStateStore

Struct MemoryPoolStateStore 

Source
pub struct MemoryPoolStateStore { /* private fields */ }
Expand description

In-memory PoolStateStore for tests and the trait’s reference semantics. Not durable — drops with the process. The runtime uses the redb-backed impl in crates/node.

Implementations§

Source§

impl MemoryPoolStateStore

Source

pub fn new() -> Self

Construct an empty store.

Source

pub fn len(&self) -> usize

Snapshot the current entry count. Useful in tests to assert that rejected vouchers did not write through. A poisoned mutex reports 0 rather than panicking.

Source

pub fn is_empty(&self) -> bool

true when no lanes are tracked.

Trait Implementations§

Source§

impl Debug for MemoryPoolStateStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryPoolStateStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PoolStateStore for MemoryPoolStateStore

Source§

fn load_all(&self) -> Result<Vec<LaneState>, StoreError>

Load every persisted lane. Called once during node bring-up so the runtime can hydrate its in-memory map before the voucher-accepting handler starts. Read more
Source§

fn record(&self, state: &LaneState) -> Result<(), StoreError>

Record the post-acceptance state for one lane in the store’s working set. A disk-backed store MAY buffer this in memory and make it durable later via flush; it is not required to fsync before returning Ok. Frontier state is safe to lose on a crash (an honest client resumes forward; an un-redeemed replay is still on-chain-payable). Read more
Source§

fn set_registered_until( &self, key: LaneKey, registered_until: u64, ) -> Result<(), StoreError>

Raise this lane’s observed on-chain registration expiry (LaneState::registered_until) to registered_until, monotonically — a lower or equal value is a no-op, and 0 (unknown) never lowers a known value. Touches ONLY that field, never the replay-critical last_* tuple, so the seller redeemer can record a fresh registration without racing a concurrent voucher advance into a lost update. A no-op for a lane with no record. Buffered like record; durability is the next flush’s job. Read more
Source§

fn set_paid_cumulative( &self, key: LaneKey, paid_cumulative: U256, ) -> Result<(), StoreError>

Raise this lane’s paid cumulative (LaneState::paid_cumulative) to paid_cumulative, monotonically — a lower or equal value is a no-op. Touches ONLY that field, never the replay-critical last_* tuple, so the seller PoolRedeemed watcher can record an observed redemption without racing a concurrent voucher advance into a lost update. A no-op for a lane with no record. Buffered like record; durability is the next flush’s job. Persisting it is what stops a restarted node from forgetting prior redemptions and re-submitting already-redeemed lanes (#2052). Read more
Source§

fn forget(&self, key: LaneKey) -> Result<(), StoreError>

Drop the persisted entry for a settled lane. A no-op if the lane has no record. Read more
Source§

fn get(&self, key: LaneKey) -> Result<Option<LaneState>, StoreError>

Point-lookup the persisted state for one lane, or None if no record exists. Used by the on-chain seller redemption path to read the latest accepted voucher (last_amount / last_bytes_delivered / last_signature) when deciding whether an accrued claim crosses the redemption threshold — always the freshest committed voucher. Read more
Source§

fn flush(&self) -> Result<(), StoreError>

Force all buffered lane state durable (fsync, for disk-backed impls). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more