Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Sep 16, 2024
1 parent fc694d4 commit 0503e07
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
19 changes: 15 additions & 4 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ use starknet::core::types::{
};
use starknet::providers::Provider;
use starknet_crypto::poseidon_hash_many;
use tokio::sync::{broadcast::Sender, mpsc::Sender as BoundedSender, Semaphore};
use tokio::sync::broadcast::Sender;
use tokio::sync::mpsc::Sender as BoundedSender;
use tokio::sync::Semaphore;
use tokio::task::JoinSet;
use tokio::time::sleep;
use tracing::{debug, error, info, trace, warn};
use tokio::task::JoinSet;

use crate::processors::event_message::EventMessageProcessor;
use crate::processors::{BlockProcessor, EventProcessor, TransactionProcessor};
Expand Down Expand Up @@ -114,7 +116,16 @@ impl<P: Provider + Send + Sync + std::fmt::Debug + 'static> Engine<P> {
shutdown_tx: Sender<()>,
block_tx: Option<BoundedSender<u64>>,
) -> Self {
Self { world: Arc::new(world), db, provider: Box::new(provider), processors: Arc::new(processors), config, shutdown_tx, block_tx, tasks: HashMap::new() }
Self {
world: Arc::new(world),
db,
provider: Box::new(provider),
processors: Arc::new(processors),
config,
shutdown_tx,
block_tx,
tasks: HashMap::new(),
}
}

pub async fn start(&mut self) -> Result<()> {
Expand Down Expand Up @@ -452,7 +463,7 @@ impl<P: Provider + Send + Sync + std::fmt::Debug + 'static> Engine<P> {
let processors = self.processors.clone();
let block_timestamp = data.blocks[&last_block];
let semaphore = semaphore.clone();

set.spawn(async move {
let _permit = semaphore.acquire().await.unwrap();
let mut local_db = db.clone();
Expand Down
9 changes: 7 additions & 2 deletions crates/torii/core/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ pub struct Sql {

impl Clone for Sql {
fn clone(&self) -> Self {
Self { world_address: self.world_address, pool: self.pool.clone(), query_queue: QueryQueue::new(self.pool.clone()), model_cache: self.model_cache.clone() }
Self {
world_address: self.world_address,
pool: self.pool.clone(),
query_queue: QueryQueue::new(self.pool.clone()),
model_cache: self.model_cache.clone(),
}
}
}

Expand Down Expand Up @@ -177,7 +182,7 @@ impl Sql {
&mut 0,
&mut 0,
);

self.query_queue.push_publish(BrokerMessage::ModelRegistered(model_registered));

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/core/src/sql_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,4 @@ async fn count_table(table_name: &str, pool: &sqlx::Pool<sqlx::Sqlite>) -> i64 {
let count: (i64,) = sqlx::query_as(&count_query).fetch_one(pool).await.unwrap();

count.0
}
}
2 changes: 1 addition & 1 deletion crates/torii/graphql/src/tests/entities_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ mod tests {
assert_eq!(subrecord.subrecord_id, 1);
Ok(())
}
}
}
2 changes: 1 addition & 1 deletion crates/torii/graphql/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,4 @@ pub async fn spinup_types_test() -> Result<SqlitePool> {
engine.process_range(data).await.unwrap();

Ok(pool)
}
}
2 changes: 1 addition & 1 deletion crates/torii/graphql/src/tests/models_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,4 @@ mod tests {

Ok(())
}
}
}

0 comments on commit 0503e07

Please sign in to comment.