Skip to content
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

feat(torii): make poll time configurable #2327

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

use clap::Parser;
use clap::{ArgAction, Parser};
use common::parse::{parse_socket_address, parse_url};
use dojo_metrics::{metrics_process, prometheus_exporter};
use dojo_world::contracts::world::WorldContractReader;
Expand Down Expand Up @@ -107,12 +108,16 @@ struct Args {
explorer: bool,

/// Chunk size of the events page when indexing using events
#[arg(long, default_value = "1000")]
#[arg(long, default_value = "1024")]
events_chunk_size: u64,

/// Enable indexing pending blocks
#[arg(long)]
#[arg(long, action = ArgAction::Set, default_value_t = true)]
index_pending: bool,

/// Polling interval in ms
#[arg(long, default_value = "500")]
polling_interval: u64,
}

#[tokio::main]
Expand Down Expand Up @@ -184,7 +189,7 @@ async fn main() -> anyhow::Result<()> {
start_block: args.start_block,
events_chunk_size: args.events_chunk_size,
index_pending: args.index_pending,
..Default::default()
polling_interval: Duration::from_millis(args.polling_interval),
},
shutdown_tx.clone(),
Some(block_tx),
Expand Down
10 changes: 5 additions & 5 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) const LOG_TARGET: &str = "tori_core::engine";

#[derive(Debug)]
pub struct EngineConfig {
pub block_time: Duration,
pub polling_interval: Duration,
pub start_block: u64,
pub events_chunk_size: u64,
pub index_pending: bool,
Expand All @@ -43,10 +43,10 @@ pub struct EngineConfig {
impl Default for EngineConfig {
fn default() -> Self {
Self {
block_time: Duration::from_secs(1),
polling_interval: Duration::from_millis(500),
start_block: 0,
events_chunk_size: 1000,
index_pending: false,
events_chunk_size: 1024,
index_pending: true,
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<P: Provider + Sync> Engine<P> {
}
}
};
sleep(self.config.block_time).await;
sleep(self.config.polling_interval).await;
} => {}
}
}
Expand Down
Loading