Skip to content

Commit

Permalink
send query only when required
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed Oct 9, 2024
1 parent 20d7edb commit bb356e0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions crates/torii/core/src/sql/erc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,18 @@ impl Sql {
}

Check warning on line 335 in crates/torii/core/src/sql/erc.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/sql/erc.rs#L334-L335

Added lines #L334 - L335 were not covered by tests

pub async fn apply_cache_diff(&mut self) -> Result<()> {
self.executor.send(QueryMessage::new(
"".to_string(),
vec![],
QueryType::ApplyBalanceDiff(ApplyBalanceDiffQuery {
erc_cache: mem::replace(
&mut self.local_cache.erc_cache,
HashMap::with_capacity(64),
),
}),
))?;
if !self.local_cache.erc_cache.is_empty() {
self.executor.send(QueryMessage::new(
"".to_string(),
vec![],
QueryType::ApplyBalanceDiff(ApplyBalanceDiffQuery {
erc_cache: mem::replace(
&mut self.local_cache.erc_cache,
HashMap::with_capacity(64),
),
}),
))?;
}
Ok(())
}

Check warning on line 351 in crates/torii/core/src/sql/erc.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/sql/erc.rs#L337-L351

Added lines #L337 - L351 were not covered by tests
}

0 comments on commit bb356e0

Please sign in to comment.