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<D, P> State<D, P>
impl<D, P> State<D, P>
pub fn new(tree: MerkleTree<D, P>, txs: TxStorage<D, P::Fr>) -> Self
Sourcepub fn add_hashes(&mut self, at_index: u64, hashes: &[Num<P::Fr>])
pub fn add_hashes(&mut self, at_index: u64, hashes: &[Num<P::Fr>])
Add OUT + 1 hashes to the tree
Sourcepub fn add_full_tx(
&mut self,
at_index: u64,
hashes: &[Num<P::Fr>],
account: Option<Account<P::Fr>>,
notes: &[(u64, Note<P::Fr>)],
)
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
Sourcepub fn add_account(&mut self, at_index: u64, account: Account<P::Fr>)
pub fn add_account(&mut self, at_index: u64, account: Account<P::Fr>)
Cache account at specified index.
pub fn get_all_txs(&self) -> Vec<(u64, Transaction<P::Fr>)>
pub fn get_usable_notes(&self) -> Vec<(u64, Note<P::Fr>)>
Sourcepub fn earliest_usable_index(&self) -> u64
pub fn earliest_usable_index(&self) -> u64
Return an index of a earliest usable note.
Sourcepub fn earliest_usable_index_optimistic(
&self,
optimistic_accounts: &[(u64, Account<P::Fr>)],
optimistic_notes: &[(u64, Note<P::Fr>)],
) -> u64
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
Sourcepub fn total_balance(&self) -> Num<P::Fr>
pub fn total_balance(&self) -> Num<P::Fr>
Returns user’s total balance (account + available notes).
pub fn account_balance(&self) -> Num<P::Fr>
pub fn note_balance(&self) -> Num<P::Fr>
pub fn rollback(&mut self, to_index: u64)
Auto Trait Implementations§
impl<D, P> Freeze for State<D, P>
impl<D, P> RefUnwindSafe for State<D, P>
impl<D, P> Send for State<D, P>
impl<D, P> Sync for State<D, P>
impl<D, P> Unpin for State<D, P>
impl<D, P> UnwindSafe for State<D, P>
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
Mutably borrows from an owned value. Read more
Source§impl<Out, S> FromSeed<S> for Outwhere
S: SeedBoxGen<Out>,
impl<Out, S> FromSeed<S> for Outwhere
S: SeedBoxGen<Out>,
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>
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 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>
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