Skip to content

Commit

Permalink
Fixed startup blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
josevazf committed Oct 11, 2024
1 parent 99f428f commit 1c95930
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/db/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ diesel::table! {

diesel::joinable!(backfill_jobs -> chains (chain_id));

diesel::allow_tables_to_appear_in_same_query!(accounts, backfill_jobs, chains, txs,);
diesel::allow_tables_to_appear_in_same_query!(
accounts,
backfill_jobs,
chains,
txs,
);
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::Arc;

use color_eyre::eyre::Result;
use config::Config;
use reth_provider::BlockNumReader;
use tokio::{signal, sync::mpsc};
use tokio_util::{sync::CancellationToken, task::TaskTracker};
use tracing::info;
Expand All @@ -31,6 +32,13 @@ async fn main() -> Result<()> {
let db = Db::connect(&config, account_tx, job_tx).await?;
let chain = db.setup_chain(&config.chain).await?;
let provider_factory = Arc::new(RethProviderFactory::new(&config, &chain)?);

let provider = provider_factory.get()?;
let latest = provider.last_block_number().unwrap();
db.update_chain(chain.chain_id as u64, latest).await?;

let chain = db.setup_chain(&config.chain).await?;

let token = CancellationToken::new();

// setup each task
Expand Down
2 changes: 1 addition & 1 deletion src/sync/backfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum StopStrategy {

impl StopStrategy {
fn is_on_finish(&self) -> bool {
matches!(self, StopStrategy::Token(_))
matches!(self, StopStrategy::OnFinish)
}
}

Expand Down

0 comments on commit 1c95930

Please sign in to comment.