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
sourceimpl<P> State<MemoryDatabase, P>where
P: PoolParams,
P::Fr: 'static,
impl<P> State<MemoryDatabase, P>where
P: PoolParams,
P::Fr: 'static,
sourceimpl<D, P> State<D, P>where
D: KeyValueDB,
P: PoolParams,
P::Fr: 'static,
impl<D, P> State<D, P>where
D: KeyValueDB,
P: PoolParams,
P::Fr: 'static,
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: &Vec<(u64, Account<P::Fr>)>,
optimistic_notes: &Vec<(u64, Note<P::Fr>)>
) -> u64
pub fn earliest_usable_index_optimistic(
&self,
optimistic_accounts: &Vec<(u64, Account<P::Fr>)>,
optimistic_notes: &Vec<(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> RefUnwindSafe for State<D, P>where
D: RefUnwindSafe,
P: RefUnwindSafe,
<P as PoolParams>::Fr: RefUnwindSafe,
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more