chore: move consensus instantiation to fn (#5208)

This commit is contained in:
Matthias Seitz
2023-10-28 08:57:47 +02:00
committed by GitHub
parent a9fa281816
commit ffe1a88417

View File

@ -262,12 +262,7 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
info!(target: "reth::cli", "{}", DisplayHardforks::from(self.chain.hardforks().clone()));
let consensus: Arc<dyn Consensus> = if self.dev.dev {
debug!(target: "reth::cli", "Using auto seal");
Arc::new(AutoSealConsensus::new(Arc::clone(&self.chain)))
} else {
Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)))
};
let consensus = self.consensus();
self.init_trusted_nodes(&mut config);
@ -558,6 +553,18 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
}
}
/// Returns the [Consensus] instance to use.
///
/// By default this will be a [BeaconConsensus] instance, but if the `--dev` flag is set, it
/// will be an [AutoSealConsensus] instance.
pub fn consensus(&self) -> Arc<dyn Consensus> {
if self.dev.dev {
Arc::new(AutoSealConsensus::new(Arc::clone(&self.chain)))
} else {
Arc::new(BeaconConsensus::new(Arc::clone(&self.chain)))
}
}
/// Constructs a [Pipeline] that's wired to the network
#[allow(clippy::too_many_arguments)]
async fn build_networked_pipeline<DB, Client>(