mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-07-25 09:03:11 +00:00
fix(wallet): suggestion fix 3
This commit is contained in:
parent
70ac6b3294
commit
93eed48112
@ -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(
|
||||
|
||||
@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user