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

fix(sync): inject a state object instead of using a global state #172

Merged
merged 1 commit into from
Mar 4, 2022
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
7 changes: 5 additions & 2 deletions crates/pathfinder/src/bin/pathfinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use pathfinder_lib::{
ethereum, rpc, sequencer, state,
storage::Storage,
};
use std::sync::Arc;
use tracing::info;
use web3::{transports::Http, Web3};

Expand Down Expand Up @@ -38,12 +39,14 @@ async fn main() -> anyhow::Result<()> {

let storage = Storage::migrate(database_path.into()).unwrap();
let sequencer = sequencer::Client::new(network_chain).unwrap();
let sync_state = Arc::new(state::SyncState::default());

let _sync_handle = tokio::spawn(state::sync(
storage.clone(),
eth_transport,
network_chain,
sequencer.clone(),
sync_state.clone(),
));

// TODO: the error could be recovered, but currently it's required for startup. There should
Expand All @@ -56,8 +59,8 @@ async fn main() -> anyhow::Result<()> {
.await
.context("Creating python process for call handling. Have you setup and activate the python `VIRTUAL_ENV` in the `py` directory?")?;

let api =
rpc::api::RpcApi::new(storage, sequencer, network_chain).with_call_handling(call_handle);
let api = rpc::api::RpcApi::new(storage, sequencer, network_chain, sync_state)
.with_call_handling(call_handle);

let (_rpc_handle, local_addr) =
rpc::run_server(config.http_rpc_addr, api).context("Starting the RPC server")?;
Expand Down
Loading