Skip to content
Draft
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
5 changes: 3 additions & 2 deletions src/eth/follower/importer/importer_supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ pub async fn start_importer(
.run(resume_from, sync_interval, chain, stop_at_block)
.await?;
}
ImporterMode::FakeLeader =>
ImporterMode::FakeLeader => {
FakeLeader::new(executor, miner, storage, Arc::clone(&chain))
.run(resume_from, sync_interval, chain, stop_at_block)
.await?,
.await?;
}
}
Ok(())
}
Expand Down
27 changes: 4 additions & 23 deletions src/eth/rpc/blockchain_client/blockchain_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use jsonrpsee::ws_client::WsClientBuilder;
use tokio::sync::RwLock;
use tokio::sync::RwLockReadGuard;

use super::importer_pagination::ImporterPaginationClient;
use crate::GlobalState;
use crate::alias::AlloyBytes;
use crate::alias::AlloyTransaction;
Expand All @@ -36,7 +37,7 @@ use crate::log_and_err;

#[derive(Debug)]
pub struct BlockchainClient {
http: HttpClient,
pub(super) http: HttpClient,
pub http_url: String,
ws: Option<RwLock<WsClient>>,
ws_url: Option<String>,
Expand Down Expand Up @@ -159,33 +160,13 @@ impl BlockchainClient {
/// Fetches a block by number with receipts.
pub async fn fetch_block_and_receipts(&self, block_number: BlockNumber) -> anyhow::Result<Option<ExternalBlockWithReceipts>> {
tracing::debug!(%block_number, "fetching block");

let number = to_json_value(block_number);
let result = self
.http
.request::<Option<ExternalBlockWithReceipts>, _>("stratus_getBlockAndReceipts", [number])
.await;

match result {
Ok(block) => Ok(block),
Err(e) => log_and_err!(reason = e, "failed to fetch block with receipts"),
}
ImporterPaginationClient::new(self).fetch_block_and_receipts(block_number).await
}

/// Fetches a block by number with changes.
pub async fn fetch_block_with_changes(&self, block_number: BlockNumber) -> anyhow::Result<Option<(BlockRocksdb, BlockChangesRocksdb)>> {
tracing::debug!(%block_number, "fetching block with changes");

let number = to_json_value(block_number);
let result = self
.http
.request::<Option<(BlockRocksdb, BlockChangesRocksdb)>, _>("stratus_getBlockWithChanges", [number])
.await;

match result {
Ok(block) => Ok(block),
Err(e) => log_and_err!(reason = e, "failed to fetch block with changes"),
}
ImporterPaginationClient::new(self).fetch_block_with_changes(block_number).await
}

/// Fetches a block by number.
Expand Down
Loading
Loading