Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: trigger bootstrap right after init #354

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/bin/dolos/bootstrap/mithril.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::{debug, info, warn};

use crate::{feedback::Feedback, MithrilConfig};

#[derive(Debug, clap::Args, Default)]
#[derive(Debug, clap::Args)]
pub struct Args {
#[arg(long, default_value = "./snapshot")]
download_dir: String,
Expand All @@ -30,6 +30,18 @@ pub struct Args {
retain_snapshot: bool,
}

impl Default for Args {
fn default() -> Self {
Self {
download_dir: "./snapshot".to_string(),
skip_if_not_empty: Default::default(),
skip_validation: Default::default(),
skip_download: Default::default(),
retain_snapshot: Default::default(),
}
}
}

struct MithrilFeedback {
download_pb: indicatif::ProgressBar,
validate_pb: indicatif::ProgressBar,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dolos/bootstrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Command {
}
}

#[derive(Debug, Parser)]
#[derive(Debug, Parser, Default)]
pub struct Args {
#[command(subcommand)]
command: Option<Command>,
Expand Down
3 changes: 1 addition & 2 deletions src/bin/dolos/bootstrap/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub fn run(config: &crate::Config, _args: &Args, _feedback: &Feedback) -> miette
.into_diagnostic()
.context("initializing WAL")?;

println!("WAL initialized");
println!("run `dolos daemon` to start the node and sync the chain from origin");
println!("Data initialized to sync from origin");

Ok(())
}
15 changes: 13 additions & 2 deletions src/bin/dolos/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use std::{
str::FromStr,
};

use crate::feedback::Feedback;

mod include;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -412,7 +414,11 @@ impl ConfigEditor {
}
}

pub fn run(config: miette::Result<super::Config>, args: &Args) -> miette::Result<()> {
pub fn run(
config: miette::Result<super::Config>,
args: &Args,
feedback: &Feedback,
) -> miette::Result<()> {
config
.map(|x| ConfigEditor(x, None))
.unwrap_or_default()
Expand All @@ -423,9 +429,14 @@ pub fn run(config: miette::Result<super::Config>, args: &Args) -> miette::Result

println!("config saved to dolos.toml");

let config = super::Config::new(&None)
.into_diagnostic()
.context("parsing configuration")?;

super::bootstrap::run(&config, &super::bootstrap::Args::default(), &feedback)?;

println!("\nDolos is ready!");
println!("- run `dolos daemon` to start the node");
println!("- run `dolos bootstrap` to load a Mithril snapshot");

Ok(())
}
2 changes: 1 addition & 1 deletion src/bin/dolos/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn main() -> Result<()> {
// configuration, that is why we pass the whole result and let the command logic decide what
// to do with it.
#[cfg(feature = "utils")]
(config, Command::Init(args)) => init::run(config, &args),
(config, Command::Init(args)) => init::run(config, &args, &feedback),

#[cfg(feature = "utils")]
(Ok(config), Command::Data(args)) => data::run(&config, &args, &feedback),
Expand Down
Loading