fn cast_ballot_f(sender: T::AccountId, reference_index: ReferenceIndex, ballot: Ballot) -> Result {
        let mut accounts_aye = <VotedAccounts<T>>::get((reference_index, 0));
        let mut accounts_nay = <VotedAccounts<T>>::get((reference_index, 1));
        // keep track of voter's id in aye or nay vector in Vote
        // Voter can change his vote b/w aye and nay
        // Voter cannot vote twice
        match ballot {
            Ballot::Aye => {
                ensure!(!accounts_aye.contains(&sender), "You have already voted aye.");
                // if sender has voted for the other option, remove from the array
                if accounts_nay.contains(&sender) {
                    let i = accounts_nay.iter().position(|x| x == &sender).unwrap() as usize;
                    accounts_nay.remove(i);
                } 
                accounts_aye.push(sender.clone());
                <VotedAccounts<T>>::insert((reference_index, 0), accounts_aye);
                print("Ballot casted Aye!");
            }
            Ballot::Nay => {
                ensure!(!accounts_nay.contains(&sender), "You have already voted nay.");
                if accounts_aye.contains(&sender) {
                    let i = accounts_aye.iter().position(|x| x == &sender).unwrap() as usize;
                    accounts_aye.remove(i);
                } 
                accounts_nay.push(sender.clone());
                <VotedAccounts<T>>::insert((reference_index, 1), accounts_nay);
                print("Ballot casted Nay!");
            }
        }
        Self::deposit_event(RawEvent::Voted(sender, reference_index, ballot));
        Ok(())
    }
// keep track of accounts in array by Aye/Nay in <VotedAccounts<T>>
// TODO: lockvote_tally should check <LockBalance> for accuracy
keep track of accounts in array by Aye/Nay in >
TODO: lockvote_tally should check  for accuracy
keep track of accounts in array by Aye / Nay in > TODO : lockvote_tally should check for accuracy
fn cast_ballot_f(sender: T::AccountId, reference_index: ReferenceIndex, ballot: Ballot) -> Result {
        let mut accounts_aye = <VotedAccounts<T>>::get((reference_index, 0));
        let mut accounts_nay = <VotedAccounts<T>>::get((reference_index, 1));
        // keep track of voter's id in aye or nay vector in Vote
        // Voter can change his vote b/w aye and nay
        // Voter cannot vote twice
        match ballot {
            Ballot::Aye => {
                ensure!(!accounts_aye.contains(&sender), "You have already voted aye.");
                // if sender has voted for the other option, remove from the array
                if accounts_nay.contains(&sender) {
                    let i = accounts_nay.iter().position(|x| x == &sender).unwrap() as usize;
                    accounts_nay.remove(i);
                } 
                accounts_aye.push(sender.clone());
                <VotedAccounts<T>>::insert((reference_index, 0), accounts_aye);
                print("Ballot casted Aye!");
            }
            Ballot::Nay => {
                ensure!(!accounts_nay.contains(&sender), "You have already voted nay.");
                if accounts_aye.contains(&sender) {
                    let i = accounts_aye.iter().position(|x| x == &sender).unwrap() as usize;
                    accounts_aye.remove(i);
                } 
                accounts_nay.push(sender.clone());
                <VotedAccounts<T>>::insert((reference_index, 1), accounts_nay);
                print("Ballot casted Nay!");
            }
        }
        Self::deposit_event(RawEvent::Voted(sender, reference_index, ballot));
        Ok(())
    }
fn cast_ballot_f ( sender : T :: AccountId , reference_index : ReferenceIndex , ballot : Ballot ) -> Result { let mut accounts_aye = < VotedAccounts < T > > :: get ( ( reference_index , 0 ) ) ; let mut accounts_nay = < VotedAccounts < T > > :: get ( ( reference_index , 1 ) ) ; // keep track of voter's id in aye or nay vector in Vote // Voter can change his vote b/w aye and nay // Voter cannot vote twice match ballot { Ballot :: Aye => { ensure ! ( accounts_aye contains ( sender ) " " ) ; // if sender has voted for the other option, remove from the array if accounts_nay . contains ( & sender ) { let i = accounts_nay . iter ( ) . position ( | x | x == & sender ) . unwrap ( ) as usize ; accounts_nay . remove ( i ) ; } accounts_aye . push ( sender . clone ( ) ) ; < VotedAccounts < T > > :: insert ( ( reference_index , 0 ) , accounts_aye ) ; print ( " " ) ; } Ballot :: Nay => { ensure ! ( accounts_nay contains ( sender ) " " ) ; if accounts_aye . contains ( & sender ) { let i = accounts_aye . iter ( ) . position ( | x | x == & sender ) . unwrap ( ) as usize ; accounts_aye . remove ( i ) ; } accounts_nay . push ( sender . clone ( ) ) ; < VotedAccounts < T > > :: insert ( ( reference_index , 1 ) , accounts_nay ) ; print ( " " ) ; } } Self :: deposit_event ( RawEvent :: Voted ( sender , reference_index , ballot ) ) ; Ok ( ( ) ) }
keep track of accounts in array by Aye/Nay in <VotedAccounts<T>>
TODO: lockvote_tally should check <LockBalance> for accuracy
keep track of accounts in array by Aye / Nay in <VotedAccounts<T >> TODO : lockvote_tally should check <LockBalance > for accuracy
sender
T::AccountId
reference_index
ReferenceIndex
ballot
Ballot
sender
T::AccountId
reference_index
ReferenceIndex
ballot
Ballot