sigil-governance · voting
Source declarations, signatures and documentation for voting.
Source: sigil/node/sigil-governance/src/voting.rs. SHA-256: ea9e2356a4fd6467191be7731ecf400c8f552a47e1c915940e1ac90332873fa9.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
voting::VoteChoice
The four possible vote choices.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum VoteChoice {
Yes,
No,
Abstain,
NoWithVeto,
}Source line: 15.
voting::Vote
A single vote cast by a participant.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Vote {
/// DID of the voter.
pub voter_did: String,
/// Proposal being voted on.
pub proposal_id: String,
/// The voter's choice.
pub choice: VoteChoice,
/// Raw staked balance in micro-MINT.
pub stake_weight: u64,
/// Trust factor derived from OATS lineage score (range 0.0 ..= 2.0).
pub lineage_trust_factor: f64,
/// `stake_weight * lineage_trust_factor`, rounded and clamped.
pub effective_weight: u64,
/// Epoch at which the vote was recorded.
pub cast_epoch: u64
}Source line: 28.
voting::Vote::compute_effective_weight
Compute effective voting weight from raw stake and trust factor.
The trust factor is clamped to [0.0, 2.0] and the multiplication is
performed in floating-point then rounded, with the result clamped to
u64::MAX to avoid overflow.
#[must_use]
pub fn compute_effective_weight(stake: u64, trust_factor: f64) -> u64;Source line: 52.
voting::VotingTally
Accumulated vote totals for a single proposal.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VotingTally {
/// Proposal being tallied.
pub proposal_id: String,
/// Sum of effective weights for Yes votes.
pub yes_weight: u64,
/// Sum of effective weights for No votes.
pub no_weight: u64,
/// Sum of effective weights for Abstain votes.
pub abstain_weight: u64,
/// Sum of effective weights for NoWithVeto votes.
pub veto_weight: u64,
/// Total effective weight that has been cast (all choices).
pub total_voted_weight: u64,
/// Total effective weight eligible to vote (set externally).
pub total_eligible_weight: u64,
/// Number of individual votes cast.
pub vote_count: u32
}Source line: 73.
voting::VotingTally::new
Create an empty tally for the given proposal.
#[must_use]
pub fn new(proposal_id: impl Into<String>) -> Self;Source line: 98.
voting::VotingTally::add_vote
Record a vote, accumulating its effective weight into the correct bucket.
Returns false if the voter already has a recorded vote (use
remove_vote first to change a vote).
pub fn add_vote(&mut self, vote: &Vote) -> bool;Source line: 116.
voting::VotingTally::remove_vote
Remove a previously recorded vote so the voter may cast a new one.
Returns true if the vote was found and removed.
pub fn remove_vote(&mut self, voter_did: &str) -> bool;Source line: 131.
voting::VotingTally::compute_result
Compute the final result given proposal type and total eligible weight.
#[must_use]
pub fn compute_result(&self, proposal_type: ProposalType, total_eligible: u64) -> VotingResult;Source line: 143.
voting::VotingTally::quorum_reached
Returns true if the participation ratio meets or exceeds the minimum.
#[must_use]
pub fn quorum_reached(&self, min_participation: f64) -> bool;Source line: 179.
voting::VotingResult
The computed outcome of a vote.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VotingResult {
/// Proposal this result belongs to.
pub proposal_id: String,
/// Whether the proposal passed.
pub passed: bool,
/// Whether the proposal was vetoed.
pub vetoed: bool,
/// yes / (yes + no + veto).
pub approval_ratio: f64,
/// veto / (yes + no + veto).
pub veto_ratio: f64,
/// total_voted / total_eligible.
pub participation_ratio: f64,
/// Underlying tally data.
pub tally: VotingTally
}Source line: 213.