Skip to content
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
2 changes: 1 addition & 1 deletion rust/c509-certificate/examples/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ fn time_to_string(time: u64) -> anyhow::Result<String> {
// Attempt to convert the timestamp and handle errors if they occur
let timestamp: i64 = time
.try_into()
.map_err(|e| anyhow::anyhow!("Failed to convert time: {:?}", e))?;
.map_err(|e| anyhow::anyhow!("Failed to convert time: {e:?}"))?;

// Convert the timestamp to a DateTime and handle any potential errors
let datetime = DateTime::from_timestamp(timestamp, 0)
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/auxdata/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl TryFrom<u64> for ScriptType {

fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
0 => Err(anyhow!("Invalid script type: {}", value)),
0 => Err(anyhow!("Invalid script type: {value}")),
1 => Ok(Self::Native),
_ => Ok(Self::Plutus(value.saturating_sub(1))),
}
Expand Down
19 changes: 10 additions & 9 deletions rust/cardano-chain-follower/src/mithril_snapshot_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,18 @@ impl MithrilSnapshotConfig {

let Ok(relative_file) = tmp_file.strip_prefix(&tmp_path) else {
error!("Failed to get relative path of file.");
bail!("Failed to strip prefix: {tmp_path:?}");
bail!("Failed to strip prefix: {}", tmp_path.to_string_lossy());
};

// IF we make it here, the files are identical, so we can de-dup them safely.
// Remove the tmp file momentarily.
if tmp_file.exists() {
if let Err(error) = std::fs::remove_file(tmp_file) {
error!(
"Error removing tmp file {} : {}",
"Error removing tmp file {} : {error}",
tmp_file.to_string_lossy(),
error
);
bail!("Failed to remove tmp file: {tmp_file:?}");
bail!("Failed to remove tmp file: {}", tmp_file.to_string_lossy());
}
}

Expand All @@ -260,21 +259,23 @@ impl MithrilSnapshotConfig {
// Hardlink the src file to the tmp file.
if let Some(parent) = tmp_file.parent() {
if let Err(error) = std::fs::create_dir_all(parent) {
error!("Error creating parent dir {parent:?} for tmp file {tmp_file:?}: {error}");
error!(
"Error creating parent dir {parent:?} for tmp file {}: {error}",
tmp_file.to_string_lossy()
);
}
}
if let Err(error) = std::fs::hard_link(src_file, tmp_file) {
error!(
"Error linking src file {} to tmp file {} : {}",
"Error linking src file {} to tmp file {} : {error}",
src_file.to_string_lossy(),
tmp_file.to_string_lossy(),
error
);
bail!("Failed to link src file: {src_file:?}");
bail!("Failed to link src file: {}", src_file.to_string_lossy());
}

// And if we made it here, file was successfully de-duped. YAY.
debug!("DeDup OK: {tmp_file:?}");
debug!("DeDup OK: {tmp_file:?}",);
Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl FileDownloader for MithrilTurboDownloader {

// We only support full downloads for now.
if !matches!(download_event_type, DownloadEvent::Full { .. }) {
bail!("Unsupported Download Event Type: {:?}", download_event_type);
bail!("Unsupported Download Event Type: {download_event_type:?}");
}

let location = location.as_str();
Expand Down
12 changes: 4 additions & 8 deletions rust/cardano-chain-follower/src/turbo_downloader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ impl ParallelDownloadProcessor {
chain: Network,
) -> Result<Self> {
if cfg.chunk_size < MIN_CHUNK_SIZE {
bail!(
"Download chunk size must be at least {} bytes",
MIN_CHUNK_SIZE
);
bail!("Download chunk size must be at least {MIN_CHUNK_SIZE} bytes");
}
let file_size = get_content_length_async(url).await?;

Expand Down Expand Up @@ -595,7 +592,7 @@ impl ParallelDownloadProcessor {
let queue = worker_queue.value();
queue.send(order)?;
} else {
bail!("Expected a work queue for worker: {:?}", this_worker);
bail!("Expected a work queue for worker: {this_worker:?}");
}
} else {
// No more work, so remove the work queue from the map.
Expand Down Expand Up @@ -779,7 +776,7 @@ async fn get_content_length_async(url: &str) -> Result<usize> {
Ok(result) => result,
Err(error) => {
error!("get_content_length failed");
Err(anyhow::anyhow!("get_content_length failed: {}", error))
Err(anyhow::anyhow!("get_content_length failed: {error}"))
},
}
}
Expand All @@ -799,8 +796,7 @@ fn get_content_length(url: &str) -> Result<usize> {
if let Some(accept_ranges) = response.header(ACCEPT_RANGES.as_str()) {
if accept_ranges != "bytes" {
bail!(
"Server doesn't support HTTP range byte requests (Accept-Ranges = {})",
accept_ranges
"Server doesn't support HTTP range byte requests (Accept-Ranges = {accept_ranges})",
);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion rust/immutable-ledger/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl BlockHeader {
let prev_block_hash_type = match hash_function.as_u64() {
BLAKE3_CBOR_TAG => HashFunction::Blake3,
BLAKE_2B_CBOR_TAG => HashFunction::Blake2b,
_ => bail!(format!("Invalid hash function type {:?}", hash_function)),
_ => bail!(format!("Invalid hash function type {hash_function:?}")),
};

let prev_block_hash = cbor_decoder
Expand Down
2 changes: 1 addition & 1 deletion rust/signed_doc/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl Metadata {
let fields = serde::Deserializer::deserialize_map(fields, MetadataDeserializeVisitor)?;
let report = ProblemReport::new("Deserializing metadata from json");
let metadata = Self::from_fields(fields.into_iter().map(anyhow::Result::<_>::Ok), &report)?;
anyhow::ensure!(!report.is_problematic(), "{:?}", report);
anyhow::ensure!(!report.is_problematic(), "{report:?}");
Ok(metadata)
}

Expand Down
4 changes: 2 additions & 2 deletions rust/signed_doc/src/validator/rules/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ContentTypeRule {
ContentType::Json => {
if let Err(e) = serde_json::from_slice::<&serde_json::value::RawValue>(content)
{
anyhow::bail!("Invalid {} content: {e}", exp)
anyhow::bail!("Invalid {exp} content: {e}")
}
},
ContentType::Cbor => {
Expand All @@ -129,7 +129,7 @@ impl ContentTypeRule {
| ContentType::Plain
| ContentType::PlainHandlebars => {
// TODO: not implemented yet
anyhow::bail!("`{}` is valid but unavailable yet", exp)
anyhow::bail!("`{exp}` is valid but unavailable yet")
},
}
}
Expand Down
Loading