Remove wrong assertion from phragmen (#4515)

* remove assertion
This commit is contained in:
Kian Paimani
2020-01-13 16:48:00 +01:00
committed by GitHub
parent 2597457a7e
commit 0cd8d2c2cf
5 changed files with 117 additions and 32 deletions
+18 -6
View File
@@ -1528,18 +1528,30 @@ impl<T: Trait> Module<T> {
let mut slot_stake = BalanceOf::<T>::max_value();
for (c, s) in supports.into_iter() {
// build `struct exposure` from `support`
let mut others = Vec::new();
let mut own: BalanceOf<T> = Zero::zero();
let mut total: BalanceOf<T> = Zero::zero();
s.voters
.into_iter()
.map(|(who, value)| (who, to_balance(value)))
.for_each(|(who, value)| {
if who == c {
own = own.saturating_add(value);
} else {
others.push(IndividualExposure { who, value });
}
total = total.saturating_add(value);
});
let exposure = Exposure {
own: to_balance(s.own),
own,
others,
// This might reasonably saturate and we cannot do much about it. The sum of
// someone's stake might exceed the balance type if they have the maximum amount
// of balance and receive some support. This is super unlikely to happen, yet
// we simulate it in some tests.
total: to_balance(s.total),
others: s.others
.into_iter()
.map(|(who, value)| IndividualExposure { who, value: to_balance(value) })
.collect::<Vec<IndividualExposure<_, _>>>(),
total,
};
if exposure.total < slot_stake {
slot_stake = exposure.total;
}