Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
ensured check for already set chain, wipe after new chain set confirm…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
abhi3700 committed Jan 31, 2024
1 parent a9826fa commit ef9072f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions pulsar/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ pub(crate) async fn config(

// update (optional) the chain
if let Some(c) = chain {
config.chain = ChainConfig::from_str(&c)?;
println!("Chain updated as {:?}", c);
let new_chain = ChainConfig::from_str(&c)?;
if config.chain == new_chain.clone() {
bail!("Chain already set");
}

config.chain = new_chain.clone();

// wipe everything (farmer, node, summary) except config file
wipe(true, true, true, false).await.expect("Error while wiping.");
// if chain is changed, then wipe everything (farmer, node, summary) except
// config file
if parse_config()?.chain == new_chain {
wipe(true, true, true, false).await.expect("Error while wiping.");
}
}

// update (optional) the farm size
Expand Down
2 changes: 1 addition & 1 deletion pulsar/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl FarmerConfig {
}

/// Enum for Chain
#[derive(Deserialize, Serialize, Default, Clone, Debug, EnumIter)]
#[derive(Deserialize, Serialize, Default, Clone, Debug, EnumIter, PartialEq)]
pub(crate) enum ChainConfig {
#[default]
Gemini3g,
Expand Down

0 comments on commit ef9072f

Please sign in to comment.