Skip to main content

SeenNonces

Struct SeenNonces 

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

The nonces already spent, so a ticket is single use.

A ring and not a set: the thing that writes to it is a verified ticket with a bounded life, so what has to be remembered is one life’s worth of them and never the whole history. MAX_LIFE_MS is ten minutes; a box selling a renewal a second for ten minutes fills six hundred slots.

In memory, and that is a stated limit rather than an oversight. A monetize that restarts forgets, and a ticket replayed across that restart would be admitted — within its ten-minute life, by somebody who had already captured it, to buy the tenant it already names another period of the same subscription. The exposure is one duplicate renewal of the attacker’s own account, and Purchase.Start is idempotent on its reference anyway (<product>/<tenant>/<date>), so the second one is the same order. Making it durable would mean a table, and a table is worth its cost when the thing it prevents is worth more than a repeated no-op.

Implementations§

Source§

impl SeenNonces

Source

pub fn with_capacity(cap: usize) -> SeenNonces

Source

pub fn admit(&self, nonce: &str) -> bool

Record this nonce and say whether it was new. false means it has been spent and the ticket must be refused.

Trait Implementations§

Source§

impl Debug for SeenNonces

Source§

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

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

impl Default for SeenNonces

Source§

fn default() -> SeenNonces

Returns the “default value” for a type. 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, 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> 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.