Skip to content

Commit

Permalink
Merge pull request #2095 from b-zee/refactor-clippy
Browse files Browse the repository at this point in the history
refactor(cli/faucet): clippy suggestions
  • Loading branch information
b-zee authored Sep 6, 2024
2 parents 82bd5ee + 3c400cc commit ecf4c22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
17 changes: 7 additions & 10 deletions sn_cli/src/files/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,27 @@ impl UploadedFile {
self.filename
);
}
let serialized = rmp_serde::to_vec(&(&self.filename, &self.data_map)).map_err(|err| {
error!("Failed to serialize UploadedFile");
err
})?;
let serialized =
rmp_serde::to_vec(&(&self.filename, &self.data_map)).inspect_err(|_err| {
error!("Failed to serialize UploadedFile");
})?;

std::fs::write(&uploaded_file_path, serialized).map_err(|err| {
std::fs::write(&uploaded_file_path, serialized).inspect_err(|_err| {
error!(
"Could not write UploadedFile of {:?} to {uploaded_file_path:?}",
self.filename
);
err
})?;

Ok(())
}

pub fn read(path: &Path) -> Result<Self> {
let bytes = std::fs::read(path).map_err(|err| {
let bytes = std::fs::read(path).inspect_err(|_err| {
error!("Error while reading the UploadedFile from {path:?}");
err
})?;
let metadata = rmp_serde::from_slice(&bytes).map_err(|err| {
let metadata = rmp_serde::from_slice(&bytes).inspect_err(|_err| {
error!("Error while deserializing UploadedFile for {path:?}");
err
})?;
Ok(metadata)
}
Expand Down
3 changes: 1 addition & 2 deletions sn_faucet/src/faucet_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ use tokio::{fs, io::AsyncWriteExt};
pub async fn run_faucet_server(client: &Client) -> Result<()> {
let root_dir = get_faucet_data_dir();
let wallet = load_account_wallet_or_create_with_mnemonic(&root_dir, None)?;
claim_genesis(client, wallet).await.map_err(|err| {
claim_genesis(client, wallet).await.inspect_err(|_err| {
println!("Faucet Server couldn't start as we failed to claim Genesis");
eprintln!("Faucet Server couldn't start as we failed to claim Genesis");
error!("Faucet Server couldn't start as we failed to claim Genesis");
err
})?;

#[cfg(feature = "initial-data")]
Expand Down

0 comments on commit ecf4c22

Please sign in to comment.