Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Fixed lair keystore and config
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Sep 14, 2022
1 parent 28c173e commit 1d61567
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion crates/holochain_manager/src/holochain_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl HolochainManager {
)
.await?;

std::thread::sleep(Duration::from_millis(1000));
std::thread::sleep(Duration::from_millis(100));

// Try to connect twice. This fixes the os(111) error for now that occurs when the conducor is not ready yet.
let mut ws = match AdminWebsocket::connect(format!("ws://localhost:{}", config.admin_port))
Expand Down
1 change: 0 additions & 1 deletion crates/holochain_manager/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pub async fn launch_holochain_process(
log::info!("Launched holochain");



tauri::async_runtime::spawn(async move {
// read events such as stdout
while let Some(event) = holochain_rx.recv().await {
Expand Down
8 changes: 4 additions & 4 deletions crates/holochain_manager/src/versions/v0_0_162.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::{path::PathBuf, sync::Arc};
use url2::Url2;

// NEW_VERSION: Import the exact same types but from the new crates
use holochain_conductor_api_0_0_161::{
use holochain_conductor_api_0_0_162::{
conductor::{ConductorConfig, KeystoreConfig},
AdminInterfaceConfig, InterfaceDriver,
};
use holochain_p2p_0_0_161::kitsune_p2p::{KitsuneP2pConfig, ProxyConfig, TransportConfig, dependencies::kitsune_p2p_types::config::tuning_params_struct::KitsuneP2pTuningParams};
use holochain_p2p_0_0_162::kitsune_p2p::{KitsuneP2pConfig, ProxyConfig, TransportConfig, dependencies::kitsune_p2p_types::config::tuning_params_struct::KitsuneP2pTuningParams};

use super::{version_manager::VersionManager, HdkVersion, common::{proxy_url, boostrap_service}};

Expand All @@ -15,7 +15,7 @@ pub struct HolochainV0_0_162;
impl VersionManager for HolochainV0_0_162 {
// NEW_VERSION: Careful! Indicate here which HDK version comes bundled with this Holochain version
fn hdk_version(&self) -> HdkVersion {
HdkVersion::V0_0_151
HdkVersion::V0_0_152
}

// NEW_VERSION: Duplicate and change whatever config is necessary to change
Expand All @@ -28,7 +28,7 @@ impl VersionManager for HolochainV0_0_162 {
let mut network_config = KitsuneP2pConfig::default();
network_config.bootstrap_service = Some(boostrap_service());

let mut tuning_params = KitsuneP2pTuningParams::default();
let tuning_params = KitsuneP2pTuningParams::default();

network_config.tuning_params = Arc::new(tuning_params);

Expand Down
2 changes: 1 addition & 1 deletion crates/holochain_manager/src/versions/version_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait VersionManager {

fn lair_keystore_version(&self) -> LairKeystoreVersion {
// For now all holochain versions run the same lair keystore version
LairKeystoreVersion::V0_2_1
LairKeystoreVersion::V0_2
}

fn initial_config(
Expand Down
6 changes: 3 additions & 3 deletions crates/lair_keystore_manager/src/versions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use serde_enum_str::{Deserialize_enum_str, Serialize_enum_str};

mod init;
mod launch;
pub mod v0_2_1;
pub mod v0_2;

#[derive(Copy, Clone, Debug, PartialEq, Hash, Eq, Deserialize_enum_str, Serialize_enum_str)]
pub enum LairKeystoreVersion {
#[serde(rename = "0.2.1")]
V0_2_1,
#[serde(rename = "0.2")]
V0_2,
}

impl Into<String> for LairKeystoreVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use super::{
};
use crate::{error::LairKeystoreError, utils::create_dir_if_necessary, LairKeystoreManager};

pub struct LairKeystoreManagerV0_2_1 {
pub struct LairKeystoreManagerV0_2 {
_keystore_path: PathBuf,
connection_url: Url2,
password: String,
}

#[async_trait]
impl LairKeystoreManager for LairKeystoreManagerV0_2_1 {
impl LairKeystoreManager for LairKeystoreManagerV0_2 {
fn lair_keystore_version() -> LairKeystoreVersion {
LairKeystoreVersion::V0_2_1
LairKeystoreVersion::V0_2
}

fn is_initialized(keystore_path: PathBuf) -> bool {
Expand All @@ -40,7 +40,7 @@ impl LairKeystoreManager for LairKeystoreManagerV0_2_1 {
let connection_url =
launch_lair_keystore_process(log_level, keystore_path.clone(), password.clone()).await?;

Ok(LairKeystoreManagerV0_2_1 {
Ok(LairKeystoreManagerV0_2 {
password,
connection_url,
_keystore_path: keystore_path,
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/launcher/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use holochain_manager::errors::{LaunchHolochainError, InitializeConductorError};
use holochain_web_app_manager::error::LaunchWebAppManagerError;
use lair_keystore_manager::error::{LairKeystoreError, LaunchChildError};
use lair_keystore_manager::utils::create_dir_if_necessary;
use lair_keystore_manager::versions::v0_2_0::LairKeystoreManagerV0_2_1;
use lair_keystore_manager::versions::v0_2::LairKeystoreManagerV0_2;
use lair_keystore_manager::LairKeystoreManager;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
Expand Down Expand Up @@ -58,9 +58,9 @@ impl LauncherManager {
create_dir_if_necessary(&root_holochain_data_path())?;
create_dir_if_necessary(&root_config_path())?;

let keystore_path = keystore_data_path(LairKeystoreManagerV0_2_1::lair_keystore_version());
let keystore_path = keystore_data_path(LairKeystoreManagerV0_2::lair_keystore_version());

let is_initialized = LairKeystoreManagerV0_2_1::is_initialized(keystore_path);
let is_initialized = LairKeystoreManagerV0_2::is_initialized(keystore_path);

let keystore_status = match is_initialized {
true => KeystoreStatus::PasswordNecessary,
Expand Down Expand Up @@ -96,9 +96,9 @@ impl LauncherManager {
}

pub async fn initialize_and_launch_keystore(&mut self, password: String) -> Result<(), String> {
let keystore_path = keystore_data_path(LairKeystoreManagerV0_2_1::lair_keystore_version());
let keystore_path = keystore_data_path(LairKeystoreManagerV0_2::lair_keystore_version());

LairKeystoreManagerV0_2_1::initialize(keystore_path, password.clone())
LairKeystoreManagerV0_2::initialize(keystore_path, password.clone())
.await
.map_err(|err| format!("Error initializing the keystore: {:?}", err))?;

Expand All @@ -108,9 +108,9 @@ impl LauncherManager {
}

pub async fn launch_keystore(&mut self, password: String) -> Result<(), String> {
let keystore_path = keystore_data_path(LairKeystoreManagerV0_2_1::lair_keystore_version());
let keystore_path = keystore_data_path(LairKeystoreManagerV0_2::lair_keystore_version());
let lair_keystore_manager =
LairKeystoreManagerV0_2_1::launch(self.config.log_level, keystore_path, password.clone())
LairKeystoreManagerV0_2::launch(self.config.log_level, keystore_path, password.clone())
.await
.map_err(|err| format!("Error launching the keystore: {:?}", err))?;

Expand Down
6 changes: 1 addition & 5 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
],
"resources": [],
"externalBin": [
"bins/holochain-v0.0.145",
"bins/holochain-v0.0.152",
"bins/holochain-v0.0.154",
"bins/holochain-v0.0.156",
"bins/holochain-v0.0.161",
"bins/holochain-v0.0.162",
"bins/lair-keystore",
"bins/caddy"
],
Expand Down

0 comments on commit 1d61567

Please sign in to comment.