Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lean_client/containers/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,7 @@ impl State {

/// Get the number of validators (since PersistentList doesn't have len())
pub fn validator_count(&self) -> usize {
let mut count: u64 = 0;
loop {
match self.validators.get(count) {
Ok(_) => count += 1,
Err(_) => break,
}
}
count as usize
self.validators.len_usize()
}

pub fn get_justifications(&self) -> BTreeMap<Bytes32, Vec<bool>> {
Expand Down Expand Up @@ -567,7 +560,7 @@ impl State {
}

if let Some(votes) = justifications.get(&target_root) {
let num_validators = self.validators.len_u64() as usize;
let num_validators = self.validators.len_usize();
let count = votes.iter().filter(|&&v| v).count();
let threshold = (2 * num_validators).div_ceil(3);

Expand Down
Loading