Struct State

Source
pub struct State<D: KeyValueDB, P: PoolParams> {
    pub tree: MerkleTree<D, P>,
    pub latest_account_index: Option<u64>,
    pub latest_note_index: u64,
    /* private fields */
}

Fields§

§tree: MerkleTree<D, P>§latest_account_index: Option<u64>§latest_note_index: u64

Latest owned note index

Implementations§

Source§

impl<P> State<InMemory, P>
where P: PoolParams, P::Fr: 'static,

Source

pub fn init_test(params: P) -> Self

Source§

impl<D, P> State<D, P>
where D: KeyValueDB, P: PoolParams, P::Fr: 'static,

Source

pub fn new(tree: MerkleTree<D, P>, txs: TxStorage<D, P::Fr>) -> Self

Source

pub fn add_hashes(&mut self, at_index: u64, hashes: &[Num<P::Fr>])

Add OUT + 1 hashes to the tree

Source

pub fn add_full_tx( &mut self, at_index: u64, hashes: &[Num<P::Fr>], account: Option<Account<P::Fr>>, notes: &[(u64, Note<P::Fr>)], )

Add hashes, account, and notes to state

Source

pub fn add_account(&mut self, at_index: u64, account: Account<P::Fr>)

Cache account at specified index.

Source

pub fn add_note(&mut self, at_index: u64, note: Note<P::Fr>)

Caches a note at specified index.

Source

pub fn get_all_txs(&self) -> Vec<(u64, Transaction<P::Fr>)>

Source

pub fn get_usable_notes(&self) -> Vec<(u64, Note<P::Fr>)>

Source

pub fn earliest_usable_index(&self) -> u64

Return an index of a earliest usable note.

Source

pub fn earliest_usable_index_optimistic( &self, optimistic_accounts: &[(u64, Account<P::Fr>)], optimistic_notes: &[(u64, Note<P::Fr>)], ) -> u64

Return an index of a earliest usable note including optimistic state

Source

pub fn total_balance(&self) -> Num<P::Fr>

Returns user’s total balance (account + available notes).

Source

pub fn account_balance(&self) -> Num<P::Fr>

Source

pub fn note_balance(&self) -> Num<P::Fr>

Source

pub fn rollback(&mut self, to_index: u64)

Auto Trait Implementations§

§

impl<D, P> Freeze for State<D, P>
where D: Freeze, P: Freeze, <P as PoolParams>::Fr: Freeze,

§

impl<D, P> RefUnwindSafe for State<D, P>

§

impl<D, P> Send for State<D, P>
where P: Send, <P as PoolParams>::Fr: Send,

§

impl<D, P> Sync for State<D, P>
where P: Sync, <P as PoolParams>::Fr: Sync,

§

impl<D, P> Unpin for State<D, P>
where D: Unpin, P: Unpin, <P as PoolParams>::Fr: Unpin,

§

impl<D, P> UnwindSafe for State<D, P>
where D: UnwindSafe, P: UnwindSafe, <P as PoolParams>::Fr: UnwindSafe,

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<Out, S> FromSeed<S> for Out
where S: SeedBoxGen<Out>,

Source§

fn from_seed(seed: &[u8]) -> Out

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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