wait times between nested deployments

This commit is contained in:
evan-schott 2024-01-08 14:25:01 -08:00
parent e46b40f929
commit 47a5e1a44d

View File

@ -18,6 +18,7 @@ use super::*;
use snarkos_cli::commands::{Deploy as SnarkOSDeploy, Developer};
use snarkvm::cli::helpers::dotenv_private_key;
use std::path::PathBuf;
use tracing_subscriber::fmt::time;
/// Deploys an Aleo program.
#[derive(Parser, Debug)]
@ -32,6 +33,10 @@ pub struct Deploy {
pub(crate) private_key: Option<String>,
#[clap(long, help = "Disables building of the project before deployment", default_value = "false")]
pub(crate) no_build: bool,
#[clap(long, help = "Disables recursive deployment of dependencies", default_value = "false")]
pub(crate) non_recursive: bool,
#[clap(long, help = "Custom wait gap between consecutive deployments", default_value = "12")]
pub(crate) wait_gap: u64,
}
impl Command for Deploy {
@ -60,13 +65,17 @@ impl Command for Deploy {
Some(dotenv_private_key().map_err(CliError::failed_to_read_environment_private_key)?.to_string());
}
let mut all_paths: Vec<(String, PathBuf)> = Vec::new();
// Extract post-ordered list of local dependencies' paths from `leo.lock`
let mut all_paths: Vec<(String, PathBuf)> = context.local_dependency_paths()?;
if !self.non_recursive {
all_paths = context.local_dependency_paths()?;
}
// Add the parent program to be deployed last
all_paths.push((project_name, context.dir()?.join("build")));
for (name, path) in all_paths {
for (index, (name, path)) in all_paths.iter().enumerate() {
// Set deploy arguments
let deploy = SnarkOSDeploy::try_parse_from([
"snarkos",
@ -84,10 +93,14 @@ impl Command for Deploy {
])
.unwrap();
dbg!(&deploy); // TODO: remove
// Deploy program
Developer::Deploy(deploy).parse().map_err(CliError::failed_to_execute_deploy)?;
// Sleep for `wait_gap` seconds.
// This helps avoid parents from being serialized before children.
if index < all_paths.len() - 1 {
std::thread::sleep(std::time::Duration::from_secs(self.wait_gap));
}
}
Ok(())