From 920fb17b3acb965a35732ccba66c566de9c602bd Mon Sep 17 00:00:00 2001 From: Vytenis Narmontas Date: Tue, 27 Jan 2026 23:13:09 +0200 Subject: [PATCH] Use PersistentList length methods --- lean_client/containers/src/state.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lean_client/containers/src/state.rs b/lean_client/containers/src/state.rs index 6d56e7a..67bbfab 100644 --- a/lean_client/containers/src/state.rs +++ b/lean_client/containers/src/state.rs @@ -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> { @@ -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);