Struct chain_impl_mockchain::vote::VotePlanManager
source · pub struct VotePlanManager {
id: VotePlanId,
plan: Arc<VotePlan>,
committee: Arc<HashSet<CommitteeId>>,
proposal_managers: ProposalManagers,
}
Expand description
Manage the vote plan and the associated votes in the ledger
this structure manage the lifespan of the vote plan, the votes casted and the associated parameters
Fields§
§id: VotePlanId
§plan: Arc<VotePlan>
§committee: Arc<HashSet<CommitteeId>>
§proposal_managers: ProposalManagers
Implementations§
source§impl VotePlanManager
impl VotePlanManager
pub fn new(plan: VotePlan, committee: HashSet<CommitteeId>) -> Self
pub fn id(&self) -> &VotePlanId
pub fn plan(&self) -> &VotePlan
pub fn statuses(&self) -> VotePlanStatus
pub fn can_vote(&self, date: BlockDate) -> bool
pub fn can_committee(&self, date: BlockDate) -> bool
pub fn committee_set(&self) -> &HashSet<CommitteeId>
sourcepub fn vote_plan_elapsed(&self, date: BlockDate) -> bool
pub fn vote_plan_elapsed(&self, date: BlockDate) -> bool
return true if the vote plan has elapsed i.e. the vote is no longer interesting to track in the ledger and it can be GCed.
fn valid_committee(&self, id: &CommitteeId) -> bool
sourcepub fn vote(
&self,
block_date: BlockDate,
identifier: Identifier,
cast: VoteCast,
token_distribution: TokenDistribution<'_, ()>
) -> Result<Self, VoteError>
pub fn vote( &self, block_date: BlockDate, identifier: Identifier, cast: VoteCast, token_distribution: TokenDistribution<'_, ()> ) -> Result<Self, VoteError>
attempt to apply the vote to one of the proposals
If the given identifier already had a vote, the previous vote will be discarded and only the new one will be kept.
errors
- this function may fail if the proposal identifier is different
- if the proposal index is not one one of the proposal listed
- if the block_date show it is no longer valid to cast a vote for any of the managed proposals
- if the payload type of the vote is not the expected one
pub fn public_tally<F>( &self, block_date: BlockDate, governance: &Governance, sig: CommitteeId, token_distribution: TokenDistribution<'_, ()>, f: F ) -> Result<Self, VoteError>where F: FnMut(&VoteAction),
pub fn private_tally<F>( &self, block_date: BlockDate, decrypted_tally: &DecryptedPrivateTally, governance: &Governance, sig: CommitteeId, token_distribution: TokenDistribution<'_, ()>, f: F ) -> Result<Self, VoteError>where F: FnMut(&VoteAction),
Trait Implementations§
source§impl Clone for VotePlanManager
impl Clone for VotePlanManager
source§fn clone(&self) -> VotePlanManager
fn clone(&self) -> VotePlanManager
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 PartialEq<VotePlanManager> for VotePlanManager
impl PartialEq<VotePlanManager> for VotePlanManager
source§fn eq(&self, other: &VotePlanManager) -> bool
fn eq(&self, other: &VotePlanManager) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for VotePlanManager
impl StructuralEq for VotePlanManager
impl StructuralPartialEq for VotePlanManager
Auto Trait Implementations§
impl RefUnwindSafe for VotePlanManager
impl Send for VotePlanManager
impl Sync for VotePlanManager
impl Unpin for VotePlanManager
impl UnwindSafe for VotePlanManager
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