mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 05:51:02 +00:00
Tidy Democracy (#10867)
* add test * Assorted refactorings * complete test * saturating math * final check * use `default` Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
@@ -183,7 +183,7 @@ impl<Balance: Saturating + Ord + Zero + Copy, BlockNumber: Ord + Copy + Zero, Ac
|
||||
match self {
|
||||
Voting::Direct { votes, prior, .. } =>
|
||||
votes.iter().map(|i| i.1.balance()).fold(prior.locked(), |a, i| a.max(i)),
|
||||
Voting::Delegating { balance, .. } => *balance,
|
||||
Voting::Delegating { balance, prior, .. } => *balance.max(&prior.locked()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,4 +199,11 @@ impl<Balance: Saturating + Ord + Zero + Copy, BlockNumber: Ord + Copy + Zero, Ac
|
||||
*d = delegations;
|
||||
*p = prior;
|
||||
}
|
||||
|
||||
pub fn prior(&self) -> &PriorLock<BlockNumber, Balance> {
|
||||
match self {
|
||||
Voting::Direct { prior, .. } => prior,
|
||||
Voting::Delegating { prior, .. } => prior,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user