Skip to content

Commit

Permalink
more cleanup of blob source set
Browse files Browse the repository at this point in the history
  • Loading branch information
joewagner committed Feb 18, 2025
1 parent 5a325a5 commit 56b2c5f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fendermint/actors/blobs/src/state/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,16 @@ pub struct BlobSourceSet {
size: u64,
}

fn convert_slice_to_array(slice: &[u8]) -> Result<[u8; 32], &'static str> {
fn convert_slice_to_array(slice: &[u8]) -> Result<[u8; 32], ActorError> {
if slice.len() == 32 {
Ok(slice.try_into().unwrap()) // This will panic if the length is not 32, so better to handle it safely
let arr = slice.try_into().map_err(|e| {
ActorError::illegal_argument(format!("cannot convert slice to array: {}", e))
})?;
Ok(arr)
} else {
Err("Slice does not have exactly 32 elements")
Err(ActorError::illegal_argument(String::from(
"Slice does not have exactly 32 elements",
)))
}
}

Expand Down

0 comments on commit 56b2c5f

Please sign in to comment.