-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opt(torii-core): move off queryqueue for executing tx #2460
Changes from 54 commits
01ce338
e0ec767
6097a60
043f669
9d7d0e7
9314438
f9a136f
b883343
7771fdf
60c9069
cd52f0f
045eed0
045e4ae
388ba1e
b7acef5
b94ad7a
c13ff59
7fc27d5
260845c
a7e4f1f
8cf4452
2bcf226
3242ac4
ef3e4ba
299c0b9
e4404f1
663234a
c998428
994abc5
65612fa
13b1ba7
0c31327
afa2a0a
ef9fafc
4ec379c
d393896
1730bfc
b708081
7758cf9
607cd06
d48dd30
6d4b99f
baf7f35
c4f288a
5dac220
28633b4
fd3c377
4cabea5
ee86042
43246b6
706c7fb
9c9e0a3
6b6f5a6
61f0a4b
63cca75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,12 @@ use sqlx::SqlitePool; | |
use starknet::core::types::Felt; | ||
use starknet::providers::jsonrpc::HttpTransport; | ||
use starknet::providers::JsonRpcClient; | ||
use tempfile::NamedTempFile; | ||
use tokio::sync::broadcast; | ||
use tokio::sync::broadcast::Sender; | ||
use tokio_stream::StreamExt; | ||
use torii_core::engine::{Engine, EngineConfig, IndexingFlags, Processors}; | ||
use torii_core::executor::Executor; | ||
use torii_core::processors::event_message::EventMessageProcessor; | ||
use torii_core::processors::generate_event_processors_map; | ||
use torii_core::processors::metadata_update::MetadataUpdateProcessor; | ||
|
@@ -64,7 +66,7 @@ struct Args { | |
|
||
/// Database filepath (ex: indexer.db). If specified file doesn't exist, it will be | ||
/// created. Defaults to in-memory database | ||
#[arg(short, long, default_value = ":memory:")] | ||
#[arg(short, long, default_value = "")] | ||
database: String, | ||
|
||
/// Specify a block to start indexing from, ignored if stored head exists | ||
|
@@ -163,8 +165,12 @@ async fn main() -> anyhow::Result<()> { | |
}) | ||
.expect("Error setting Ctrl-C handler"); | ||
|
||
let tempfile = NamedTempFile::new()?; | ||
let database_path = | ||
if args.database.is_empty() { tempfile.path().to_str().unwrap() } else { &args.database }; | ||
|
||
let mut options = | ||
SqliteConnectOptions::from_str(&args.database)?.create_if_missing(true).with_regexp(); | ||
SqliteConnectOptions::from_str(database_path)?.create_if_missing(true).with_regexp(); | ||
|
||
// Performance settings | ||
options = options.auto_vacuum(SqliteAutoVacuum::None); | ||
|
@@ -185,7 +191,12 @@ async fn main() -> anyhow::Result<()> { | |
// Get world address | ||
let world = WorldContractReader::new(args.world_address, provider.clone()); | ||
|
||
let db = Sql::new(pool.clone(), args.world_address).await?; | ||
let (mut executor, sender) = Executor::new(pool.clone(), shutdown_tx.clone()).await?; | ||
tokio::spawn(async move { | ||
executor.run().await.unwrap(); | ||
}); | ||
|
||
Comment on lines
+194
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohayo, sensei! Consider improving error handling in the executor task. The creation and running of the Consider handling potential errors more gracefully: tokio::spawn(async move {
if let Err(e) = executor.run().await {
error!("Executor encountered an error: {:?}", e);
// Optionally, you could send a shutdown signal here
// let _ = shutdown_tx.send(());
}
}); This change will log the error instead of panicking, allowing the application to continue running even if the executor encounters an issue. |
||
let db = Sql::new(pool.clone(), args.world_address, sender.clone()).await?; | ||
|
||
let processors = Processors { | ||
event: generate_event_processors_map(vec![ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohayo, sensei! Consider more robust error handling for temporary file path.
The new logic for handling the database path is a good improvement. However, using
unwrap()
ontempfile.path().to_str()
could potentially panic if the path contains non-UTF-8 characters. Consider using a more robust error handling approach.Here's a suggestion to improve error handling:
This change will propagate the error up the call stack instead of panicking, allowing for more graceful error handling.