Struct chain_impl_mockchain::multisig::Ledger
source · pub struct Ledger {
accounts: Ledger<Identifier, ()>,
declarations: Hamt<DefaultHasher, Identifier, Declaration>,
}
Fields§
§accounts: Ledger<Identifier, ()>
§declarations: Hamt<DefaultHasher, Identifier, Declaration>
Implementations§
source§impl Ledger
impl Ledger
pub fn restore( accounts: Vec<(Identifier, AccountState<()>)>, declarations: Vec<(Identifier, Declaration)> ) -> Self
sourcepub fn add_account(
&self,
declaration: &Declaration
) -> Result<Self, LedgerError>
pub fn add_account( &self, declaration: &Declaration ) -> Result<Self, LedgerError>
Add a new multisig declaration into the ledger.
If the identifier is already present, error out.
sourcepub fn remove_account(&self, ident: &Identifier) -> Result<Self, LedgerError>
pub fn remove_account(&self, ident: &Identifier) -> Result<Self, LedgerError>
Remove a declaration from this ledger
pub fn add_value( &self, identifier: &Identifier, value: Value ) -> Result<Self, LedgerError>
pub fn iter_accounts(&self) -> Iter<'_, Identifier, ()> ⓘ
pub fn iter_declarations(&self) -> HamtIter<'_, Identifier, Declaration>
sourcepub fn spend(
&self,
identifier: &Identifier,
counter: SpendingCounter,
value: Value
) -> Result<Self, LedgerError>
pub fn spend( &self, identifier: &Identifier, counter: SpendingCounter, value: Value ) -> Result<Self, LedgerError>
Spend value from an existing account.
If the account doesn’t exist, or if the value is too much to spend,
or if the spending counter doesn’t match, it throws a LedgerError
.
sourcepub(crate) fn spend_with_no_counter_check(
&self,
identifier: &Identifier,
counter: SpendingCounter,
value: Value
) -> Result<Self, LedgerError>
pub(crate) fn spend_with_no_counter_check( &self, identifier: &Identifier, counter: SpendingCounter, value: Value ) -> Result<Self, LedgerError>
Spend value from an existing account without spending counter check.
If the account doesn’t exist, or if the value is too much to spend,
it throws a LedgerError
.
sourcepub(crate) fn get_declaration_by_id(
&self,
identifier: &Identifier
) -> Result<&Declaration, LedgerError>
pub(crate) fn get_declaration_by_id( &self, identifier: &Identifier ) -> Result<&Declaration, LedgerError>
Gets the &Declaration
for the given &Identifier
.
sourcepub fn set_delegation(
&self,
identifier: &Identifier,
delegation: &DelegationType
) -> Result<Self, LedgerError>
pub fn set_delegation( &self, identifier: &Identifier, delegation: &DelegationType ) -> Result<Self, LedgerError>
Set the delegation of an account in this ledger
pub fn get_total_value(&self) -> Result<Value, ValueError>
Trait Implementations§
source§impl PartialEq<Ledger> for Ledger
impl PartialEq<Ledger> for Ledger
impl Eq for Ledger
impl StructuralEq for Ledger
impl StructuralPartialEq for Ledger
Auto Trait Implementations§
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnwindSafe for Ledger
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