Struct chain_impl_mockchain::vote::ledger::VotePlanLedger
source · pub struct VotePlanLedger {
pub(crate) plans: Hamt<DefaultHasher, VotePlanId, VotePlanManager>,
}
Fields§
§plans: Hamt<DefaultHasher, VotePlanId, VotePlanManager>
Implementations§
source§impl VotePlanLedger
impl VotePlanLedger
pub fn new() -> Self
sourcepub fn apply_vote(
&self,
block_date: BlockDate,
identifier: Identifier,
vote: VoteCast,
token_distribution: TokenDistribution<'_, ()>
) -> Result<Self, VotePlanLedgerError>
pub fn apply_vote( &self, block_date: BlockDate, identifier: Identifier, vote: VoteCast, token_distribution: TokenDistribution<'_, ()> ) -> Result<Self, VotePlanLedgerError>
attempt to apply the vote to the appropriate Vote Proposal
errors
can fail if:
- the vote plan id does not exist;
- the proposal’s index does not exist;
- it is no longer possible to vote (the date to vote expired)
sourcepub fn add_vote_plan(
&self,
current_date: BlockDate,
vote_plan: VotePlan,
committee: HashSet<CommitteeId>
) -> Result<Self, VotePlanLedgerError>
pub fn add_vote_plan( &self, current_date: BlockDate, vote_plan: VotePlan, committee: HashSet<CommitteeId> ) -> Result<Self, VotePlanLedgerError>
add the vote plan in a new VotePlanLedger
the given VotePlanLedger
is not modified and instead a new VotePlanLedger
is
returned. They share read-only memory.
errors if
- the vote_plan is set to finished votes in the past
- the vote_plan has already started
sourcepub fn apply_committee_result<F>(
&self,
block_date: BlockDate,
governance: &Governance,
tally: &VoteTally,
sig: TallyProof,
token_distribution: TokenDistribution<'_, ()>,
f: F
) -> Result<Self, VotePlanLedgerError>where
F: FnMut(&VoteAction),
pub fn apply_committee_result<F>( &self, block_date: BlockDate, governance: &Governance, tally: &VoteTally, sig: TallyProof, token_distribution: TokenDistribution<'_, ()>, f: F ) -> Result<Self, VotePlanLedgerError>where F: FnMut(&VoteAction),
apply the committee result for the associated vote plan
Errors
This function may fail:
- if the Committee time has elapsed
Trait Implementations§
source§impl Clone for VotePlanLedger
impl Clone for VotePlanLedger
source§fn clone(&self) -> VotePlanLedger
fn clone(&self) -> VotePlanLedger
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 Default for VotePlanLedger
impl Default for VotePlanLedger
source§impl PartialEq<VotePlanLedger> for VotePlanLedger
impl PartialEq<VotePlanLedger> for VotePlanLedger
source§fn eq(&self, other: &VotePlanLedger) -> bool
fn eq(&self, other: &VotePlanLedger) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for VotePlanLedger
impl StructuralEq for VotePlanLedger
impl StructuralPartialEq for VotePlanLedger
Auto Trait Implementations§
impl RefUnwindSafe for VotePlanLedger
impl Send for VotePlanLedger
impl Sync for VotePlanLedger
impl Unpin for VotePlanLedger
impl UnwindSafe for VotePlanLedger
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