Skip to content

Commit

Permalink
fix various clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Jul 6, 2024
1 parent 401e038 commit acacce2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
15 changes: 11 additions & 4 deletions crates/corro-agent/src/agent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,22 @@ pub async fn handle_emptyset(
}

if process {

for (actor, changes) in &mut buf {
while !changes.is_empty() {
let change = changes.pop_front().unwrap();
match process_emptyset(agent.clone(), bookie.clone(), *actor, &change).await {
Ok(()) => {
// cost -= change.0.len();
cost -= change.0.iter().map(|versions| cmp::min((versions.end().0 - versions.start().0) as usize + 1, 20)).sum::<usize>();
cost -= change
.0
.iter()
.map(|versions| {
cmp::min(
(versions.end().0 - versions.start().0) as usize + 1,
20,
)
})
.sum::<usize>();
}
Err(e) => {
warn!("encountered error when processing emptyset - {e}");
Expand All @@ -470,7 +478,6 @@ pub async fn handle_emptyset(
}
}
}

}

println!("shutting down handle empties loop");
Expand Down Expand Up @@ -849,7 +856,7 @@ pub async fn handle_sync(
let mut last_cleared: HashMap<ActorId, Option<Timestamp>> = HashMap::new();

for (actor_id, _) in chosen.clone() {
last_cleared.insert(actor_id, get_last_cleared_ts(&bookie, &actor_id).await);
last_cleared.insert(actor_id, get_last_cleared_ts(bookie, &actor_id).await);
}

let start = Instant::now();
Expand Down
2 changes: 1 addition & 1 deletion crates/corro-agent/src/agent/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ async fn get_rows(
let changes: Vec<Change>;
let seqs = if let Some(seq) = versions.1.clone() {
let seq_query = " and seq >= ? and seq <= ?";
query = query + seq_query;
query += seq_query;
let mut prepped = conn.prepare(&query)?;
changes = prepped
.query_map((version, seq.start(), seq.end()), row_to_change)?
Expand Down
7 changes: 5 additions & 2 deletions crates/corro-agent/src/api/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,11 +1448,14 @@ pub async fn parallel_sync(
for res in counts.iter() {
match res {
Err(e) => error!("could not properly recv from peer: {e}"),
Ok((actor_id, _)) => members.update_sync_ts(&actor_id, ts),
Ok((actor_id, _)) => members.update_sync_ts(actor_id, ts),
};
}

Ok(counts.into_iter().map(|res| res.map(|i| i.1)).flatten().sum::<usize>())
Ok(counts
.into_iter()
.flat_map(|res| res.map(|i| i.1))
.sum::<usize>())
}

#[tracing::instrument(skip(agent, bookie, their_actor_id, read, write), fields(actor_id = %their_actor_id), err)]
Expand Down

0 comments on commit acacce2

Please sign in to comment.