From 90e0eaf53c9a2e951bdf1f14ee9923ea939fbe4c Mon Sep 17 00:00:00 2001 From: Sere Mezzo Date: Thu, 31 Jul 2025 15:22:21 -0400 Subject: [PATCH 1/2] CLI arg to skip interactive archive mode on fullnode init --- tools/config/src/config_cli.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/config/src/config_cli.rs b/tools/config/src/config_cli.rs index 0b3134397..ad3924b7d 100644 --- a/tools/config/src/config_cli.rs +++ b/tools/config/src/config_cli.rs @@ -84,6 +84,9 @@ enum ConfigSub { /// path to libra config and data files defaults to $HOME/.libra #[clap(long)] home_path: Option, + /// optional, whether to use archive mode (full history) or fast sync mode + #[clap(long)] + archive_mode: Option, }, } @@ -209,20 +212,28 @@ impl ConfigCli { } // Initialize fullnode configuration - Some(ConfigSub::FullnodeInit { home_path }) => { + Some(ConfigSub::FullnodeInit { + home_path, + archive_mode, + }) => { download_genesis(home_path.to_owned()).await?; println!("downloaded genesis block"); - let sync_options = vec!["Fast Sync (default)", "Archive (full history)"]; - let selection = Select::new() - .with_prompt("choose fullnode sync mode") - .default(0) - .items(&sync_options) - .interact()?; - let archive_mode = selection != 0; + let archive = archive_mode.unwrap_or_else(|| { + let sync_options = vec!["Fast Sync (default)", "Archive (full history)"]; + + let selection = Select::new() + .with_prompt("choose fullnode sync mode") + .default(0) + .items(&sync_options) + .interact() + .expect("user did not select sync mode"); + + selection != 0 + }); // You can now use `archive_mode` to configure the fullnode accordingly. - let p = init_fullnode_yaml(home_path.to_owned(), true, archive_mode).await?; + let p = init_fullnode_yaml(home_path.to_owned(), true, archive).await?; println!("config created at {}", p.display()); From c73f49a19f4c53912f6a6f5e496a240611dd441e Mon Sep 17 00:00:00 2001 From: Nella Forte Date: Thu, 31 Jul 2025 15:45:33 -0400 Subject: [PATCH 2/2] order of ops --- tools/config/src/config_cli.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/config/src/config_cli.rs b/tools/config/src/config_cli.rs index ad3924b7d..bb6a0f3bf 100644 --- a/tools/config/src/config_cli.rs +++ b/tools/config/src/config_cli.rs @@ -216,9 +216,6 @@ impl ConfigCli { home_path, archive_mode, }) => { - download_genesis(home_path.to_owned()).await?; - println!("downloaded genesis block"); - let archive = archive_mode.unwrap_or_else(|| { let sync_options = vec!["Fast Sync (default)", "Archive (full history)"]; @@ -232,6 +229,9 @@ impl ConfigCli { selection != 0 }); + println!("downloading genesis block"); + download_genesis(home_path.to_owned()).await?; + // You can now use `archive_mode` to configure the fullnode accordingly. let p = init_fullnode_yaml(home_path.to_owned(), true, archive).await?;