Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Aug 4, 2022
1 parent bacbb5a commit b9f5a36
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions frame/staking/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ impl<T: Config> Pallet<T> {
let mut nominators_taken = 0u32;
// track every nominator iterated over, but not necessarily added to `all_voters`
let mut nominators_seen = 0u32;
// cache the total-issuance once in this function
let weight_of = Self::weight_of_fn();
let mut nominators_iter = T::SortedListProvider::iter();

while nominators_taken < nominators_quota && nominators_seen < nominators_quota * 2 {
Expand All @@ -942,18 +944,24 @@ impl<T: Config> Pallet<T> {
if let Some(Nominations { submitted_in, mut targets, suppressed: _ }) =
<Nominators<T>>::get(&nominator)
{
log!(
trace,
"fetched nominator {:?} with weight {:?}",
nominator,
weight_of(&nominator)
);
targets.retain(|stash| {
slashing_spans
.get(stash)
.map_or(true, |spans| submitted_in >= spans.last_nonzero_slash())
});

if !targets.len().is_zero() {
all_voters.push((nominator.clone(), Self::weight_of(&nominator), targets));
all_voters.push((nominator.clone(), weight_of(&nominator), targets));
nominators_taken.saturating_inc();
}
} else {
log!(error, "invalid item in `SortedListProvider`: {:?}", nominator)
log!(error, "DEFENSIVE: invalid item in `SortedListProvider`: {:?}", nominator)
}
}

Expand Down

0 comments on commit b9f5a36

Please sign in to comment.