Skip to content

Commit

Permalink
Fixed UID backwards compatibilty
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Aug 24, 2022
1 parent b6439a5 commit 6d9e4f7
Show file tree
Hide file tree
Showing 23 changed files with 199 additions and 537 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
$HcPath = Get-Command holochain | Select-Object -ExpandProperty Definition
Copy-Item $HcPath -Destination src-tauri/bins/holochain-v0.0.154-x86_64-pc-windows-msvc.exe
cargo install --locked holochain
cargo install --locked holochain --version 0.0.156
$HcPath = Get-Command holochain | Select-Object -ExpandProperty Definition
Copy-Item $HcPath -Destination src-tauri/bins/holochain-v0.0.156-x86_64-pc-windows-msvc.exe
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.154-x86_64-apple-darwin
cargo install --locked holochain
cargo install --locked holochain --version 0.0.156
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.156-x86_64-apple-darwin
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.154-x86_64-unknown-linux-gnu
cargo install --locked holochain
cargo install --locked holochain --version 0.0.156
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.156-x86_64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.154-x86_64-unknown-linux-gnu
cargo install --locked --git https://github.com/guillemcordoba/holochain.git --rev fe3b8fde13e52b3c37b8d3e451cf5d20d18f0c3a holochain
cargo install --locked holochain --version 0.0.156
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v0.0.156-x86_64-unknown-linux-gnu
Expand Down
113 changes: 111 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/holochain_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ version = "0.1.0"
# NEW_VERSION update holochain-client-rust to the latest holochain version
holochain_client = {git = "https://github.com/matthme/holochain-client-rust", rev = "62fa357b60691fb1ee79bb03a6944837dac8b8f9"}

holochain_client_old = {package = "holochain_client", version = "=0.1.0"}

holochain_conductor_api_0_0_145 = {git = "https://github.com/guillemcordoba/holochain", package = "holochain_conductor_api", rev = "b455538b80228410417f372d828d07a7cfa9e4d5"}
holochain_p2p_0_0_145 = {git = "https://github.com/guillemcordoba/holochain", package = "holochain_p2p", rev = "b455538b80228410417f372d828d07a7cfa9e4d5"}
holochain_types_0_0_145 = {git = "https://github.com/guillemcordoba/holochain", package = "holochain_types", rev = "b455538b80228410417f372d828d07a7cfa9e4d5"}
Expand All @@ -25,10 +27,8 @@ holochain_conductor_api_0_0_154 = {git = "https://github.com/guillemcordoba/holo
holochain_p2p_0_0_154 = {git = "https://github.com/guillemcordoba/holochain", package = "holochain_p2p", rev = "38b683d0009ada21a9d79f638ca2dc3986163bd9"}
holochain_types_0_0_154 = {git = "https://github.com/guillemcordoba/holochain", package = "holochain_types", rev = "38b683d0009ada21a9d79f638ca2dc3986163bd9"}


# NEW_VERSION add corresponding crates of the new versions here


holochain_types_0_0_45 = {package = "holochain_types", version = "0.0.45"}

# NEW_VERSION add latest crates here # taken from commit instead this time
Expand Down
83 changes: 56 additions & 27 deletions crates/holochain_manager/src/holochain_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::path::Path;
use std::time::SystemTime;
use std::{fs, time::Duration};

use holochain_client::{AdminWebsocket, AgentPubKey, InstallAppBundlePayload, InstalledAppInfo};
use holochain_client::{AdminWebsocket, AgentPubKey, InstalledAppInfo};
use lair_keystore_manager::utils::create_dir_if_necessary;
use tauri::api::process::CommandChild;

use crate::versions::holochain_types_latest::prelude::{AppBundle, AppBundleSource, MembraneProof};
use crate::versions::holochain_types_latest::prelude::{AppBundle, MembraneProof};

use crate::{
config::LaunchHolochainConfig,
Expand Down Expand Up @@ -69,23 +69,24 @@ impl HolochainManager {
config.command,
conductor_config_path,
password,
).await?;
)
.await?;

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

// 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))
.await {
Ok(ws) => ws,
Err(_) => {
log::error!("[HOLOCHAIN v{}] Could not connect to the AdminWebsocket. Starting another attempt in 5 seconds.", version);
std::thread::sleep(Duration::from_millis(5000));
AdminWebsocket::connect(format!("ws://localhost:{}", config.admin_port))
.await
.map_err(|err| LaunchHolochainError::CouldNotConnectToConductor(format!("{}", err)))?
}
};

.await
{
Ok(ws) => ws,
Err(_) => {
log::error!("[HOLOCHAIN v{}] Could not connect to the AdminWebsocket. Starting another attempt in 5 seconds.", version);
std::thread::sleep(Duration::from_millis(5000));
AdminWebsocket::connect(format!("ws://localhost:{}", config.admin_port))
.await
.map_err(|err| LaunchHolochainError::CouldNotConnectToConductor(format!("{}", err)))?
}
};

let app_interface_port = {
let app_interfaces = ws.list_app_interfaces().await.or(Err(
Expand Down Expand Up @@ -136,7 +137,7 @@ impl HolochainManager {
&mut self,
app_id: String,
app_bundle: AppBundle,
uid: Option<String>,
network_seed: Option<String>,
membrane_proofs: HashMap<String, MembraneProof>,
agent_pub_key: Option<AgentPubKey>,
) -> Result<(), String> {
Expand All @@ -161,18 +162,46 @@ impl HolochainManager {
.await
.map_err(|err| format!("Could not write app bundle to temp file: {}", err))?;

let payload = InstallAppBundlePayload {
source: AppBundleSource::Path(path),
agent_key,
installed_app_id: Some(app_id.clone().into()),
membrane_proofs,
network_seed: uid, // TODO! rename uid to network_seed consistently everywhere
};
self
.ws
.install_app_bundle(payload)
.await
.map_err(|err| format!("Error install hApp bundle: {:?}", err))?;
match self.version {
HolochainVersion::V0_0_145 | HolochainVersion::V0_0_150 => {
let mut ws = holochain_client_old::AdminWebsocket::connect(format!(
"ws://localhost:{}",
self.admin_interface_port
))
.await
.map_err(|err| format!("{:?}", err))?;

let key = holochain_types_0_0_45::prelude::AgentPubKey::from_raw_39(
agent_key.get_raw_39().to_vec(),
)
.map_err(|err| format!("{:?}", err))?;

let payload = holochain_client_old::InstallAppBundlePayload {
source: holochain_types_0_0_45::prelude::AppBundleSource::Path(path),
agent_key: key,
installed_app_id: Some(app_id.clone().into()),
membrane_proofs,
uid: network_seed,
};
ws.install_app_bundle(payload)
.await
.map_err(|err| format!("Error install hApp bundle: {:?}", err))?;
}
_ => {
let payload = holochain_client::InstallAppBundlePayload {
source: crate::versions::holochain_types_latest::prelude::AppBundleSource::Path(path),
agent_key,
installed_app_id: Some(app_id.clone().into()),
membrane_proofs,
network_seed,
};
self
.ws
.install_app_bundle(payload)
.await
.map_err(|err| format!("Error install hApp bundle: {:?}", err))?;
}
}

self
.ws
Expand Down
2 changes: 1 addition & 1 deletion crates/holochain_manager/src/launch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use log;
use std::{collections::HashMap, path::PathBuf, sync::Arc, sync::Mutex};
use std::{collections::HashMap, path::PathBuf};
use tauri::api::process::{Command, CommandChild, CommandEvent};

use lair_keystore_manager::error::LaunchChildError;
Expand Down
Loading

0 comments on commit 6d9e4f7

Please sign in to comment.