mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 16:17:59 +00:00
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user