diff --git a/substrate/frame/ranked-collective/abdbee b/substrate/frame/ranked-collective/abdbee new file mode 100644 index 0000000000000..3885415439f53 --- /dev/null +++ b/substrate/frame/ranked-collective/abdbee @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACAi5QJ2BscjgPR0k07UOfItiYSgK/E7M1Ajve7oWYNmEwAAAJi3C7+Gtwu/ +hgAAAAtzc2gtZWQyNTUxOQAAACAi5QJ2BscjgPR0k07UOfItiYSgK/E7M1Ajve7oWYNmEw +AAAEAjTuk+3MWUYJpi938ze18PPjR70U1nIPlO/CxyuSqH0CLlAnYGxyOA9HSTTtQ58i2J +hKAr8TszUCO97uhZg2YTAAAAFGFtb2thdmF1bHRAZ21haWwuY29tAQ== +-----END OPENSSH PRIVATE KEY----- diff --git a/substrate/frame/ranked-collective/abdbee.pub b/substrate/frame/ranked-collective/abdbee.pub new file mode 100644 index 0000000000000..783900de33b5d --- /dev/null +++ b/substrate/frame/ranked-collective/abdbee.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICLlAnYGxyOA9HSTTtQ58i2JhKAr8TszUCO97uhZg2YT amokavault@gmail.com diff --git a/substrate/frame/ranked-collective/src/lib.rs b/substrate/frame/ranked-collective/src/lib.rs index 25eab015269ec..411fbbb3221f1 100644 --- a/substrate/frame/ranked-collective/src/lib.rs +++ b/substrate/frame/ranked-collective/src/lib.rs @@ -195,16 +195,18 @@ impl MemberRecord { #[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum VoteRecord { /// Vote was an aye with given vote weight. - Aye(Votes), + Aye(Option), /// Vote was a nay with given vote weight. - Nay(Votes), + Nay(Option), } -impl From<(bool, Votes)> for VoteRecord { - fn from((aye, votes): (bool, Votes)) -> Self { - match aye { - true => VoteRecord::Aye(votes), - false => VoteRecord::Nay(votes), +impl From<(bool, Option)> for VoteRecord { + fn from((aye, votes): (bool, Option)) -> Self { + match (aye, votes) { + (true, Some(votes)) => VoteRecord::Aye(Some(votes)), + (true, None) => VoteRecord::Aye(None), + (false, Some(votes)) => VoteRecord::Nay(Some(votes)), + (false, None) => VoteRecord::Nay(None), } } } @@ -631,29 +633,26 @@ pub mod pallet { Err(Error::::NotPolling)?, PollStatus::Ongoing(ref mut tally, class) => { match Voting::::get(&poll, &who) { - Some(Aye(votes)) => { - if votes > 0 { + Some(Aye(Some(votes))) => { tally.bare_ayes.saturating_dec(); tally.ayes.saturating_reduce(votes); - } else { - tally.out_of_rank_ayes.saturating_dec(); } - + Some(Aye(None)) => { + tally.out_of_rank_ayes.saturating_dec(); }, - Some(Nay(votes)) => { - if votes > 0 { + Some(Nay(Some(votes))) => { tally.nays.saturating_reduce(votes) - } else { - tally.out_of_rank_nays.saturating_dec(); - } + }, + Some(Nay(None)) => { + tally.out_of_rank_nays.saturating_dec(); }, None => pays = Pays::No, } let min_rank = T::MinRankOfClass::convert(class); - let votes = Self::rank_to_votes(record.rank, min_rank).unwrap_or(0); + let votes = Self::rank_to_votes(record.rank, min_rank); let vote = VoteRecord::from((aye, votes)); match votes { - 0 => { + None => { match aye { true => { tally.out_of_rank_ayes.saturating_inc(); @@ -663,7 +662,7 @@ pub mod pallet { }, } }, - _ => { + Some(votes) => { match aye { true => { tally.bare_ayes.saturating_inc();