fix(wallet): suggestion fix 3

This commit is contained in:
Pravdyvy 2026-07-24 08:02:03 +03:00
parent 70ac6b3294
commit 93eed48112
2 changed files with 10 additions and 4 deletions

View File

@ -273,7 +273,7 @@ impl WalletCore {
pub async fn client_rotation(&mut self) -> Result<()> {
self.multi_sequencer_client
.update_statistics(&mut self.statistics)
.await;
.await?;
self.multi_sequencer_client
.rotate(

View File

@ -152,7 +152,11 @@ impl MultiSequencerClient {
)
.ok_or_else(|| anyhow::anyhow!("Failed to find leader"))?;
assert_ne!(leader_list.len(), 0);
if leader_list.is_empty() {
anyhow::bail!(
"Leader search algorithm failure: Sorted out all clients during leader search"
);
}
log::info!("Chosen leaders is {leader_list:?}");
@ -322,18 +326,20 @@ impl MultiSequencerClient {
}
/// Update statistics of a leader, clear statistic updates log.
pub async fn update_statistics(&self, statistics: &mut HashMap<Url, Statistics>) {
pub async fn update_statistics(&self, statistics: &mut HashMap<Url, Statistics>) -> Result<()> {
let mut statistic_updates = self.statistic_updates.write().await;
#[expect(clippy::iter_over_hash_type, reason = "Ordering is unnecesary here")]
for (addr, statistic_updates_vec) in statistic_updates.iter() {
let leader_statistic = statistics
.get_mut(addr)
.expect("Leader statistic must be present after setup");
.ok_or_else(|| anyhow::anyhow!("Leader statistic must be present after setup"))?;
leader_statistic.apply_updates(statistic_updates_vec.as_slice());
}
statistic_updates.clear();
Ok(())
}
}