pub async fn build(self) -> ConductorResult<ConductorHandle> {
            cfg_if::cfg_if! {
                // if mock_handle is specified, return that instead of
                // a real handle
                if #[cfg(test)] {
                    if let Some(handle) = self.mock_handle {
                        return Ok(Arc::new(handle));
                    }
                }
            }

            tracing::info!(?self.config);

            let keystore = if let Some(keystore) = self.keystore {
                keystore
            } else if self.config.use_dangerous_test_keystore {
                let keystore = spawn_test_keystore().await?;
                // pre-populate with our two fixture agent keypairs
                keystore
                    .generate_sign_keypair_from_pure_entropy()
                    .await
                    .unwrap();
                keystore
                    .generate_sign_keypair_from_pure_entropy()
                    .await
                    .unwrap();
                keystore
            } else {
                spawn_lair_keystore(self.config.keystore_path.as_deref()).await?
            };
            let env_path = self.config.environment_path.clone();

            let environment =
                EnvWrite::open(env_path.as_ref(), DbKind::Conductor, keystore.clone())?;

            let wasm_environment =
                EnvWrite::open(env_path.as_ref(), DbKind::Wasm, keystore.clone())?;

            let p2p_env = Arc::new(parking_lot::Mutex::new(HashMap::new()));
            let p2p_metrics_env = Arc::new(parking_lot::Mutex::new(HashMap::new()));

            #[cfg(any(test, feature = "test_utils"))]
            let state = self.state;

            let Self {
                saf_store, config, ..
            } = self;

            let network_config = match &config.network {
                None => aingle_p2p::kitsune_p2p::KitsuneP2pConfig::default(),
                Some(config) => config.clone(),
            };
            let (cert_digest, cert, cert_priv_key) =
                keystore.get_or_create_first_tls_cert().await?;
            let tls_config =
                aingle_p2p::kitsune_p2p::dependencies::kitsune_p2p_proxy::TlsConfig {
                    cert,
                    cert_priv_key,
                    cert_digest,
                };
            let (aingle_p2p, p2p_evt) =
                aingle_p2p::spawn_aingle_p2p(network_config, tls_config).await?;

            let conductor = Conductor::new(
                environment,
                wasm_environment,
                p2p_env,
                p2p_metrics_env,
                saf_store,
                keystore,
                env_path,
                aingle_p2p,
            )
            .await?;

            #[cfg(any(test, feature = "test_utils"))]
            let conductor = Self::update_fake_state(state, conductor).await?;

            Self::finish(conductor, config, p2p_evt).await
        }
/// Initialize a "production" Conductor
Initialize a "production" Conductor
Initialize a " production " Conductor
pub async fn build(self) -> ConductorResult<ConductorHandle> {
            cfg_if::cfg_if! {
                // if mock_handle is specified, return that instead of
                // a real handle
                if #[cfg(test)] {
                    if let Some(handle) = self.mock_handle {
                        return Ok(Arc::new(handle));
                    }
                }
            }
            tracing::info!(?self.config);
            let keystore = if let Some(keystore) = self.keystore {
                keystore
            } else if self.config.use_dangerous_test_keystore {
                let keystore = spawn_test_keystore().await?;
                // pre-populate with our two fixture agent keypairs
                keystore
                    .generate_sign_keypair_from_pure_entropy()
                    .await
                    .unwrap();
                keystore
                    .generate_sign_keypair_from_pure_entropy()
                    .await
                    .unwrap();
                keystore
            } else {
                spawn_lair_keystore(self.config.keystore_path.as_deref()).await?
            };
            let env_path = self.config.environment_path.clone();
            let environment =
                EnvWrite::open(env_path.as_ref(), DbKind::Conductor, keystore.clone())?;
            let wasm_environment =
                EnvWrite::open(env_path.as_ref(), DbKind::Wasm, keystore.clone())?;
            let p2p_env = Arc::new(parking_lot::Mutex::new(HashMap::new()));
            let p2p_metrics_env = Arc::new(parking_lot::Mutex::new(HashMap::new()));
            #[cfg(any(test, feature = "test_utils"))]
            let state = self.state;
            let Self {
                saf_store, config, ..
            } = self;
            let network_config = match &config.network {
                None => aingle_p2p::kitsune_p2p::KitsuneP2pConfig::default(),
                Some(config) => config.clone(),
            };
            let (cert_digest, cert, cert_priv_key) =
                keystore.get_or_create_first_tls_cert().await?;
            let tls_config =
                aingle_p2p::kitsune_p2p::dependencies::kitsune_p2p_proxy::TlsConfig {
                    cert,
                    cert_priv_key,
                    cert_digest,
                };
            let (aingle_p2p, p2p_evt) =
                aingle_p2p::spawn_aingle_p2p(network_config, tls_config).await?;
            let conductor = Conductor::new(
                environment,
                wasm_environment,
                p2p_env,
                p2p_metrics_env,
                saf_store,
                keystore,
                env_path,
                aingle_p2p,
            )
            .await?;
            #[cfg(any(test, feature = "test_utils"))]
            let conductor = Self::update_fake_state(state, conductor).await?;
            Self::finish(conductor, config, p2p_evt).await
        }
pub async fn build ( self ) -> ConductorResult < ConductorHandle > { cfg_if :: cfg_if ! { // if mock_handle is specified, return that instead of // a real handle if [ cfg ( test ) ] { if let Some ( handle ) self mock_handle { return Ok ( Arc new ( handle ) ) } } } tracing :: info ! ( self config ) ; let keystore = if let Some ( keystore ) = self . keystore { keystore } else if self . config . use_dangerous_test_keystore { let keystore = spawn_test_keystore ( ) . await ? ; // pre-populate with our two fixture agent keypairs keystore . generate_sign_keypair_from_pure_entropy ( ) . await . unwrap ( ) ; keystore . generate_sign_keypair_from_pure_entropy ( ) . await . unwrap ( ) ; keystore } else { spawn_lair_keystore ( self . config . keystore_path . as_deref ( ) ) . await ? } ; let env_path = self . config . environment_path . clone ( ) ; let environment = EnvWrite :: open ( env_path . as_ref ( ) , DbKind :: Conductor , keystore . clone ( ) ) ? ; let wasm_environment = EnvWrite :: open ( env_path . as_ref ( ) , DbKind :: Wasm , keystore . clone ( ) ) ? ; let p2p_env = Arc :: new ( parking_lot :: Mutex :: new ( HashMap :: new ( ) ) ) ; let p2p_metrics_env = Arc :: new ( parking_lot :: Mutex :: new ( HashMap :: new ( ) ) ) ; # [ cfg ( any ( test feature " " ) ) ] let state = self . state ; let Self { saf_store , config , .. } = self ; let network_config = match & config . network { None => aingle_p2p :: kitsune_p2p :: KitsuneP2pConfig :: default ( ) , Some ( config ) => config . clone ( ) , } ; let ( cert_digest , cert , cert_priv_key ) = keystore . get_or_create_first_tls_cert ( ) . await ? ; let tls_config = aingle_p2p :: kitsune_p2p :: dependencies :: kitsune_p2p_proxy :: TlsConfig { cert , cert_priv_key , cert_digest , } ; let ( aingle_p2p , p2p_evt ) = aingle_p2p :: spawn_aingle_p2p ( network_config , tls_config ) . await ? ; let conductor = Conductor :: new ( environment , wasm_environment , p2p_env , p2p_metrics_env , saf_store , keystore , env_path , aingle_p2p , ) . await ? ; # [ cfg ( any ( test feature " " ) ) ] let conductor = Self :: update_fake_state ( state , conductor ) . await ? ; Self :: finish ( conductor , config , p2p_evt ) . await }
Initialize a "production" Conductor
Initialize a " production " Conductor
self
self