From 13441ff299b4766959b5439235dfed2071059c54 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 2 Jan 2023 14:58:31 +0100 Subject: [PATCH] style: rm redundant Pipeline::new (#682) --- bin/reth/src/node/mod.rs | 2 +- crates/stages/src/pipeline.rs | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index 7041105ed..81d392078 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -118,7 +118,7 @@ impl Command { // cloneable on its own // TODO: Remove magic numbers let fetch_client = Arc::new(network.fetch_client().await?); - let mut pipeline = reth_stages::Pipeline::new() + let mut pipeline = reth_stages::Pipeline::default() .push(HeaderStage { downloader: headers::linear::LinearDownloadBuilder::default() .batch_size(config.stages.headers.downloader_batch_size) diff --git a/crates/stages/src/pipeline.rs b/crates/stages/src/pipeline.rs index 3d527b794..6b2b15eee 100644 --- a/crates/stages/src/pipeline.rs +++ b/crates/stages/src/pipeline.rs @@ -88,14 +88,9 @@ impl Debug for Pipeline { } impl Pipeline { - /// Create a new pipeline. - pub fn new() -> Self { - Default::default() - } - /// Create a new pipeline with a channel for receiving events (see [PipelineEvent]). - pub fn new_with_channel(sender: Sender) -> Self { - Self::new().set_channel(sender) + pub fn with_channel(sender: Sender) -> Self { + Self::default().set_channel(sender) } /// Add a stage to the pipeline. @@ -371,7 +366,7 @@ mod tests { // Run pipeline tokio::spawn(async move { - Pipeline::>::new_with_channel(tx) + Pipeline::>::with_channel(tx) .push( TestStage::new(StageId("A")) .add_exec(Ok(ExecOutput { stage_progress: 20, done: true })), @@ -411,7 +406,7 @@ mod tests { // Run pipeline tokio::spawn(async move { - let mut pipeline = Pipeline::>::new() + let mut pipeline = Pipeline::>::default() .push( TestStage::new(StageId("A")) .add_exec(Ok(ExecOutput { stage_progress: 100, done: true })) @@ -487,7 +482,7 @@ mod tests { // Run pipeline tokio::spawn(async move { - Pipeline::>::new() + Pipeline::>::default() .push( TestStage::new(StageId("A")) .add_exec(Ok(ExecOutput { stage_progress: 10, done: true })) @@ -548,7 +543,7 @@ mod tests { async fn pipeline_error_handling() { // Non-fatal let db = test_utils::create_test_db(EnvKind::RW); - let result = Pipeline::>::new() + let result = Pipeline::>::default() .push( TestStage::new(StageId("NonFatal")) .add_exec(Err(StageError::Recoverable(Box::new(std::fmt::Error)))) @@ -561,7 +556,7 @@ mod tests { // Fatal let db = test_utils::create_test_db(EnvKind::RW); - let result = Pipeline::>::new() + let result = Pipeline::>::default() .push(TestStage::new(StageId("Fatal")).add_exec(Err(StageError::DatabaseIntegrity( DatabaseIntegrityError::BlockBody { number: 5 }, ))))