fix(net): handle closed channel in Spawned downloader (#1346)

This commit is contained in:
Matthias Seitz
2023-02-14 18:21:14 +01:00
committed by GitHub
parent f63c8d7e36
commit 6e89af9e8e
8 changed files with 117 additions and 65 deletions

View File

@ -134,11 +134,11 @@ impl ImportCommand {
{
let header_downloader = ReverseHeadersDownloaderBuilder::from(config.stages.headers)
.build(file_client.clone(), consensus.clone())
.as_task();
.into_task();
let body_downloader = BodiesDownloaderBuilder::from(config.stages.bodies)
.build(file_client.clone(), consensus.clone(), db)
.as_task();
.into_task();
let mut pipeline = Pipeline::builder()
.with_sync_state_updater(file_client)

View File

@ -161,7 +161,13 @@ impl Command {
info!(target: "reth::cli", "Started RPC server");
let (mut pipeline, events) = self
.build_networked_pipeline(&mut config, network.clone(), &consensus, db.clone())
.build_networked_pipeline(
&mut config,
network.clone(),
&consensus,
db.clone(),
&ctx.task_executor,
)
.await?;
ctx.task_executor.spawn(handle_events(events));
@ -186,6 +192,7 @@ impl Command {
network: NetworkHandle,
consensus: &Arc<dyn Consensus>,
db: Arc<Env<WriteMap>>,
task_executor: &TaskExecutor,
) -> eyre::Result<(Pipeline<Env<WriteMap>, impl SyncStateUpdater>, impl Stream<Item = NodeEvent>)>
{
// building network downloaders using the fetch client
@ -193,11 +200,11 @@ impl Command {
let header_downloader = ReverseHeadersDownloaderBuilder::from(config.stages.headers)
.build(fetch_client.clone(), consensus.clone())
.as_task();
.into_task_with(task_executor);
let body_downloader = BodiesDownloaderBuilder::from(config.stages.bodies)
.build(fetch_client.clone(), consensus.clone(), db.clone())
.as_task();
.into_task_with(task_executor);
let mut pipeline = self
.build_pipeline(config, header_downloader, body_downloader, network.clone(), consensus)