Skip to content

Commit

Permalink
update hpos_hc_connect
Browse files Browse the repository at this point in the history
  • Loading branch information
zo-el committed Aug 13, 2024
1 parent 503a1ce commit 0c5e81e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ mr_bundle = { version = "0.4.0-dev.4" }
hpos-config-core = { git = "https://github.com/Holo-Host/hpos-config", rev = "a36f862869cc162c843ac27ed617910d68f480cc" }
hpos-config-seed-bundle-explorer ={ git = "https://github.com/Holo-Host/hpos-config", rev = "a36f862869cc162c843ac27ed617910d68f480cc" }
chrono = "0.4.33"
hpos_hc_connect = { git = "https://github.com/holo-host/hpos-service-crates.git", rev = "2618edaaea4552713a8818dcd13b05805b5854c6" }
hpos_hc_connect = { git = "https://github.com/holo-host/hpos-service-crates.git", rev = "ae7e5dbe3880b0bb03d94c767c7e15a1b3cc989e" }
1 change: 0 additions & 1 deletion src/types/happ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tracing::warn;
#[derive(Serialize, Debug, Clone)]
pub struct InstallHappBody {
pub happ_id: String,
pub preferences: HostHappPreferences,
pub membrane_proofs: HashMap<String, MembraneProof>,
}

Expand Down
3 changes: 2 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub mod hbs;
pub mod transaction;
use holochain_types::dna::ActionHashB64;
use holochain_types::prelude::{holochain_serial, SerializedBytes};
use hpos_hc_connect::hha_types::HostSettings;
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Clone)]
pub struct HappBundle {
pub happ_id: ActionHashB64,
Expand All @@ -15,6 +15,7 @@ pub struct HappBundle {
pub jurisdictions: Vec<String>,
pub exclude_jurisdictions: bool,
pub categories: Vec<String>,
pub host_settings: HostSettings,
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, SerializedBytes)]
Expand Down
21 changes: 4 additions & 17 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use anyhow::{Context, Result};
use chrono::Utc;
use holochain_types::dna::ActionHashB64;
use holochain_types::prelude::{AppManifest, MembraneProof, SerializedBytes, UnsafeBytes};
use holofuel_types::fuel::Fuel;
use hpos_hc_connect::{
hha_agent::CoreAppAgent,
holofuel_types::{PendingTransaction, POS},
Expand All @@ -21,9 +20,7 @@ use std::{
collections::{HashMap, HashSet},
env,
process::Command,
str::FromStr,
sync::Arc,
time::Duration,
};
use tracing::{debug, error, info, trace, warn};
use url::Url;
Expand Down Expand Up @@ -90,6 +87,7 @@ pub async fn get_all_published_hosted_happs(
jurisdictions: happ.jurisdictions,
exclude_jurisdictions: happ.exclude_jurisdictions,
categories: happ.categories,
host_settings: happ.host_settings,
}
})
.collect();
Expand Down Expand Up @@ -277,6 +275,7 @@ pub async fn install_holo_hosted_happs(
exclude_jurisdictions: _,
jurisdictions: _,
categories: _,
host_settings,
} in happs
{
trace!("Trying to install {}", happ_id);
Expand All @@ -288,6 +287,7 @@ pub async fn install_holo_hosted_happs(
// ...otherwise, we proceed to install, which leads to the installation of a sl instance for this happ
if special_installed_app_id.is_some()
&& enabled_happ_ids.contains(&format!("{}::servicelogger", happ_id))
&& host_settings.is_enabled
{
// Skip the install/enable step
// NB: We expect our core-app to already be installed and enabled as we never pause/disable/uninstall it
Expand All @@ -298,7 +298,7 @@ pub async fn install_holo_hosted_happs(
}
// Iterate through all currently enabled apps
// (NB: The sole exceptions here are Hosted HoloFuel and Cloud Console, as they should always be caught by the prior condition.)
else if enabled_happ_ids.contains(&format!("{}", happ_id)) {
else if enabled_happ_ids.contains(&format!("{}", happ_id)) && host_settings.is_enabled {
trace!("App {} already installed", happ_id);
// Check if this happ was paused by the publisher in hha and disable it in holochain if so
if *is_paused {
Expand Down Expand Up @@ -334,18 +334,6 @@ pub async fn install_holo_hosted_happs(
mem_proof
);

// Hardcode servicelogger preferences for all the hosted happs installed
let preferences = HostHappPreferences {
max_fuel_before_invoice: Fuel::from_str("1000")?, // MAX_TX_AMT in holofuel is currently hard-coded to 50,000
max_time_before_invoice: Duration::default(),
price_compute: Fuel::from_str("0.025")?,
price_storage: Fuel::from_str("0.025")?,
price_bandwidth: Fuel::from_str("0.025")?,
invoice_due_in_days: 7,
jurisdiction_prefs: None,
categories_prefs: None,
};

// The installation implementation can be found in`hpos-api` here: https://github.com/Holo-Host/hpos-api-rust/blob/develop/src/handlers/install/mod.rs#L31
// NB: The `/v2/apps/hosted/install` endpoint will holo-enable the app if it is already installed and enabled on hololchain,
// ...otherwise it takes the following 5 steps:
Expand All @@ -358,7 +346,6 @@ pub async fn install_holo_hosted_happs(
// Note: This call will create the first sl clone. Additional clone handling happens above.
let body = InstallHappBody {
happ_id: happ_id.to_string(),
preferences: preferences.clone(),
membrane_proofs: mem_proof.clone(),
};
let client = reqwest::Client::new();
Expand Down

0 comments on commit 0c5e81e

Please sign in to comment.