Skip to content

Commit

Permalink
refactor(sns-w): UpgradeSteps::add_wasm is infallible and so should…
Browse files Browse the repository at this point in the history
… not return a Result (#2870)

#2837 made `UpgradeSteps::add_wasm` return a result type, even though it
cannot fail. This PR undoes that change. This results in a
simplification of the other `add_wasm` function.
  • Loading branch information
anchpop authored Nov 27, 2024
1 parent 052b852 commit 49f6907
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions rs/nns/sns-wasm/src/sns_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,9 @@ where
},
);

if let Err(err) = self.upgrade_path.add_wasm(new_latest_version) {
add_wasm_response::Result::Error(SnsWasmError { message: err })
} else {
add_wasm_response::Result::Hash(hash.to_vec())
}
self.upgrade_path.add_wasm(new_latest_version);

add_wasm_response::Result::Hash(hash.to_vec())
}
Err(e) => {
println!("{}add_wasm unable to persist WASM: {}", LOG_PREFIX, e);
Expand Down Expand Up @@ -1869,12 +1867,10 @@ impl UpgradePath {
Ok(new_latest_version)
}

pub fn add_wasm(&mut self, new_latest_version: SnsVersion) -> Result<(), String> {
pub fn add_wasm(&mut self, new_latest_version: SnsVersion) {
self.upgrade_path
.insert(self.latest_version.clone(), new_latest_version.clone());
self.latest_version = new_latest_version;

Ok(())
}

pub fn get_next_version(
Expand Down

0 comments on commit 49f6907

Please sign in to comment.