Skip to content

Commit a3f3230

Browse files
committed
fix: handled deprecated mstx_balance correctly
1 parent 788a149 commit a3f3230

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

testnet/stacks-node/src/config.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,15 @@ pub struct ConfigFile {
9595
pub burnchain: Option<BurnchainConfigFile>,
9696
pub node: Option<NodeConfigFile>,
9797
pub ustx_balance: Option<Vec<InitialBalanceFile>>,
98+
/// Deprecated: use `ustx_balance` instead
99+
pub mstx_balance: Option<Vec<InitialBalanceFile>>,
98100
pub events_observer: Option<HashSet<EventObserverConfigFile>>,
99101
pub connection_options: Option<ConnectionOptionsFile>,
100102
pub fee_estimation: Option<FeeEstimationConfigFile>,
101103
pub miner: Option<MinerConfigFile>,
102104
pub atlas: Option<AtlasConfigFile>,
103105
}
104106

105-
#[derive(Clone, Deserialize, Default)]
106-
pub struct LegacyMstxConfigFile {
107-
pub mstx_balance: Option<Vec<InitialBalanceFile>>,
108-
}
109-
110107
impl ConfigFile {
111108
pub fn from_path(path: &str) -> Result<ConfigFile, String> {
112109
let content = fs::read_to_string(path).map_err(|e| format!("Invalid path: {}", &e))?;
@@ -118,13 +115,16 @@ impl ConfigFile {
118115
pub fn from_str(content: &str) -> Result<ConfigFile, String> {
119116
let mut config: ConfigFile =
120117
toml::from_str(content).map_err(|e| format!("Invalid toml: {}", e))?;
121-
let legacy_config: LegacyMstxConfigFile = toml::from_str(content).unwrap();
122-
if let Some(mstx_balance) = legacy_config.mstx_balance {
123-
warn!("'mstx_balance' inside toml config is deprecated, replace with 'ustx_balance'");
124-
config.ustx_balance = match config.ustx_balance {
125-
Some(balance) => Some([balance, mstx_balance].concat()),
126-
None => Some(mstx_balance),
127-
};
118+
if let Some(mstx_balance) = config.mstx_balance.take() {
119+
warn!("'mstx_balance' in the config is deprecated; please use 'ustx_balance' instead.");
120+
match config.ustx_balance {
121+
Some(ref mut ustx_balance) => {
122+
ustx_balance.extend(mstx_balance);
123+
}
124+
None => {
125+
config.ustx_balance = Some(mstx_balance);
126+
}
127+
}
128128
}
129129
Ok(config)
130130
}

0 commit comments

Comments
 (0)