Struct chain_impl_mockchain::accounting::account::account_state::AccountState
source · pub struct AccountState<Extra> {
pub spending: SpendingCounterIncreasing,
pub delegation: DelegationType,
pub value: Value,
pub tokens: Hamt<DefaultHasher, TokenIdentifier, Value>,
pub last_rewards: LastRewards,
pub extra: Extra,
}
Fields§
§spending: SpendingCounterIncreasing
§delegation: DelegationType
§value: Value
§tokens: Hamt<DefaultHasher, TokenIdentifier, Value>
§last_rewards: LastRewards
§extra: Extra
Implementations§
source§impl<Extra> AccountState<Extra>
impl<Extra> AccountState<Extra>
pub fn new_reward(epoch: Epoch, v: Value, extra: Extra) -> Self
sourcepub fn delegation(&self) -> &DelegationType
pub fn delegation(&self) -> &DelegationType
Get referencet to delegation setting
pub fn value(&self) -> Value
source§impl<Extra: Clone> AccountState<Extra>
impl<Extra: Clone> AccountState<Extra>
sourcepub fn add_value(&self, v: Value) -> Result<Self, ValueError>
pub fn add_value(&self, v: Value) -> Result<Self, ValueError>
Same as add() except use a ValueError
sourcepub fn add(&self, v: Value) -> Result<Self, LedgerError>
pub fn add(&self, v: Value) -> Result<Self, LedgerError>
Add a value to an account state
Only error if value is overflowing
sourcepub fn add_rewards(&self, e: Epoch, v: Value) -> Result<Self, ValueError>
pub fn add_rewards(&self, e: Epoch, v: Value) -> Result<Self, ValueError>
Add Rewards to the account value but also as the last_reward
sourcepub fn spend(
&self,
spending: SpendingCounter,
v: Value
) -> Result<Option<Self>, LedgerError>
pub fn spend( &self, spending: SpendingCounter, v: Value ) -> Result<Option<Self>, LedgerError>
Spends value from an account state, and returns the new state.
Note that this also increments the counter, as this function is usually used for spending.
sourcepub(crate) fn spend_unchecked(
&self,
counter: SpendingCounter,
v: Value
) -> Result<Option<Self>, LedgerError>
pub(crate) fn spend_unchecked( &self, counter: SpendingCounter, v: Value ) -> Result<Option<Self>, LedgerError>
Spends value from an account state, and returns the new state.
Note that this also increments the counter, but does not fail if the given counter fails to match the current one. However, it does throw a warning.
sourcepub fn token_add(
&self,
token: TokenIdentifier,
v: Value
) -> Result<Self, LedgerError>
pub fn token_add( &self, token: TokenIdentifier, v: Value ) -> Result<Self, LedgerError>
Add a value to a token in an account state
Only error if value is overflowing
sourcepub fn set_delegation(&self, delegation: DelegationType) -> Self
pub fn set_delegation(&self, delegation: DelegationType) -> Self
Set delegation
Trait Implementations§
source§impl Arbitrary for AccountState<()>
impl Arbitrary for AccountState<()>
source§impl<Extra: Clone> Clone for AccountState<Extra>
impl<Extra: Clone> Clone for AccountState<Extra>
source§fn clone(&self) -> AccountState<Extra>
fn clone(&self) -> AccountState<Extra>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<Extra: Debug> Debug for AccountState<Extra>
impl<Extra: Debug> Debug for AccountState<Extra>
source§impl<Extra: PartialEq> PartialEq<AccountState<Extra>> for AccountState<Extra>
impl<Extra: PartialEq> PartialEq<AccountState<Extra>> for AccountState<Extra>
source§fn eq(&self, other: &AccountState<Extra>) -> bool
fn eq(&self, other: &AccountState<Extra>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<Extra: Eq> Eq for AccountState<Extra>
impl<Extra> StructuralEq for AccountState<Extra>
impl<Extra> StructuralPartialEq for AccountState<Extra>
Auto Trait Implementations§
impl<Extra> RefUnwindSafe for AccountState<Extra>where Extra: RefUnwindSafe,
impl<Extra> Send for AccountState<Extra>where Extra: Send,
impl<Extra> Sync for AccountState<Extra>where Extra: Sync,
impl<Extra> Unpin for AccountState<Extra>where Extra: Unpin,
impl<Extra> UnwindSafe for AccountState<Extra>where Extra: UnwindSafe,
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