diff --git a/node/src/chain.rs b/node/src/chain.rs index 98e25a005..d3ab13302 100644 --- a/node/src/chain.rs +++ b/node/src/chain.rs @@ -61,6 +61,9 @@ pub struct ChainSrv { event_sender: Sender, genesis_timestamp: u64, dusk_key: BlsPublicKey, + + #[cfg(feature = "archive")] + archive: Archive, } #[async_trait] @@ -72,7 +75,6 @@ impl network: Arc>, db: Arc>, vm: Arc>, - #[cfg(feature = "archive")] archive: Archive, ) -> anyhow::Result<()> { let tip = Self::load_tip( db.read().await.deref(), @@ -93,7 +95,7 @@ impl network, vm, #[cfg(feature = "archive")] - archive, + self.archive.clone(), self.max_consensus_queue_size, self.event_sender.clone(), self.dusk_key, @@ -256,6 +258,7 @@ impl ChainSrv { event_sender: Sender, genesis_timestamp: u64, dusk_key: BlsPublicKey, + #[cfg(feature = "archive")] archive: Archive, ) -> Self { info!( "ChainSrv::new with keys_path: {}, max_inbound_size: {}", @@ -270,6 +273,8 @@ impl ChainSrv { event_sender, genesis_timestamp, dusk_key, + #[cfg(feature = "archive")] + archive, } } diff --git a/node/src/lib.rs b/node/src/lib.rs index 678231c65..afb9b84d2 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -22,8 +22,6 @@ use std::net::SocketAddr; use std::sync::Arc; use std::time::{Duration, Instant}; -#[cfg(feature = "archive")] -use archive::Archive; use async_trait::async_trait; use node_data::message::payload::Inv; use node_data::message::{AsyncQueue, Message}; @@ -120,7 +118,6 @@ pub trait LongLivedService: network: Arc>, database: Arc>, vm: Arc>, - #[cfg(feature = "archive")] achive: Archive, ) -> anyhow::Result<()> { Ok(()) } @@ -192,7 +189,6 @@ impl Node { pub async fn initialize( &self, services: &mut [Box>], - #[cfg(feature = "archive")] archive: Archive, ) -> anyhow::Result<()> { // Run lazy-initialization of all registered services for service in services.iter_mut() { @@ -202,8 +198,6 @@ impl Node { self.network.clone(), self.database.clone(), self.vm_handler.clone(), - #[cfg(feature = "archive")] - archive.clone(), ) .await?; } diff --git a/rusk/src/lib/builder/node.rs b/rusk/src/lib/builder/node.rs index 9dc190dab..609a31568 100644 --- a/rusk/src/lib/builder/node.rs +++ b/rusk/src/lib/builder/node.rs @@ -228,6 +228,8 @@ impl RuskNodeBuilder { node_sender.clone(), self.genesis_timestamp, *crate::DUSK_CONSENSUS_KEY, + #[cfg(feature = "archive")] + archive.clone(), ); if self.command_revert { chain_srv @@ -235,8 +237,6 @@ impl RuskNodeBuilder { node.inner().network(), node.inner().database(), node.inner().vm_handler(), - #[cfg(feature = "archive")] - archive, ) .await?; return chain_srv.revert_last_final().await; @@ -291,13 +291,7 @@ impl RuskNodeBuilder { archivist: archive.clone(), })); - node.inner() - .initialize( - &mut service_list, - #[cfg(feature = "archive")] - archive, - ) - .await?; + node.inner().initialize(&mut service_list).await?; node.inner().spawn_all(service_list).await?; Ok(())