pub fn vote_result(&self, votes: &HashMap<u64, bool>) -> VoteResult {
        if self.is_empty() {
            // By convention, the elections on an empty config win. This comes in
            // handy with joint quorums because it'll make a half-populated joint
            // quorum behave like a majority quorum
            return VoteResult::VoteWon;
        }
        let (against, agree, missing) =
            self.votes
                .iter()
                .fold((0, 0, 0), |(mut against, mut agree, mut missing), id| {
                    if let Some(v) = votes.get(id) {
                        if *v {
                            agree += 1
                        } else {
                            against += 1
                        }
                    } else {
                        missing += 1;
                    }
                    (against, agree, missing)
                });
        // vote counts for no and yes, responsibility
        let q = self.len() / 2 + 1;
        debug!("agree:{}, missing:{}, q:{}", agree, missing, q);
        if agree >= q {
            return VoteResult::VoteWon;
        }
        if agree + missing >= q {
            return VoteResult::VotePending;
        }
        VoteResult::VoteLost
    }
/// VoteResult takes a mapping of voters to yes/no (true/false) votes and returns
/// a result indicating whether the vote is pending (i.e. neither a quorum of
/// yes/no has been reached), won (a quorum of yes has been reached), or lost (a
/// quorum of no has been reached).
VoteResult takes a mapping of voters to yes/no (true/false) votes and returns
a result indicating whether the vote is pending , won (a quorum of yes has been reached), or lost (a
quorum of no has been reached).
VoteResult takes a mapping of voters to yes / no ( true / false ) votes and returns a result indicating whether the vote is pending won ( a quorum of yes has been reached ) or lost ( a quorum of no has been reached ) .
pub fn vote_result(&self, votes: &HashMap<u64, bool>) -> VoteResult {
        if self.is_empty() {
            // By convention, the elections on an empty config win. This comes in
            // handy with joint quorums because it'll make a half-populated joint
            // quorum behave like a majority quorum
            return VoteResult::VoteWon;
        }
        let (against, agree, missing) =
            self.votes
                .iter()
                .fold((0, 0, 0), |(mut against, mut agree, mut missing), id| {
                    if let Some(v) = votes.get(id) {
                        if *v {
                            agree += 1
                        } else {
                            against += 1
                        }
                    } else {
                        missing += 1;
                    }
                    (against, agree, missing)
                });
        // vote counts for no and yes, responsibility
        let q = self.len() / 2 + 1;
        debug!("agree:{}, missing:{}, q:{}", agree, missing, q);
        if agree >= q {
            return VoteResult::VoteWon;
        }
        if agree + missing >= q {
            return VoteResult::VotePending;
        }
        VoteResult::VoteLost
    }
pub fn vote_result ( & self , votes : & HashMap < u64 , bool > ) -> VoteResult { if self . is_empty ( ) { // By convention, the elections on an empty config win. This comes in // handy with joint quorums because it'll make a half-populated joint // quorum behave like a majority quorum return VoteResult :: VoteWon ; } let ( against , agree , missing ) = self . votes . iter ( ) . fold ( ( 0 , 0 , 0 ) , | ( mut against , mut agree , mut missing ) , id | { if let Some ( v ) = votes . get ( id ) { if * v { agree += 1 } else { against += 1 } } else { missing += 1 ; } ( against , agree , missing ) } ) ; // vote counts for no and yes, responsibility let q = self . len ( ) / 2 + 1 ; debug ! ( " " agree missing q ) ; if agree >= q { return VoteResult :: VoteWon ; } if agree + missing >= q { return VoteResult :: VotePending ; } VoteResult :: VoteLost }
VoteResult takes a mapping of voters to yes/no (true/false) votes and returns
a result indicating whether the vote is pending (i.e.
VoteResult takes a mapping of voters to yes / no ( true / false ) votes and returns a result indicating whether the vote is pending ( i . e .
&self
votes
&HashMap<u64, bool>