Skip to content

Commit

Permalink
fix(kona-host): set explicit types (#421)
Browse files Browse the repository at this point in the history
* fix: index bytes

* fix data bytes

* fix

* lint
  • Loading branch information
ratankaliani committed Aug 9, 2024
1 parent e069eb4 commit 44146a5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,19 @@ where
anyhow::bail!("Invalid hint data length: {}", hint_data.len());
}

let hash: B256 = hint_data[0..32]
.as_ref()
let hash_data_bytes: [u8; 32] = hint_data[0..32]
.try_into()
.map_err(|e| anyhow!("Failed to convert bytes to B256: {e}"))?;
let index = u64::from_be_bytes(
hint_data[32..40]
.as_ref()
.try_into()
.map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?,
);
let timestamp = u64::from_be_bytes(
hint_data[40..48]
.as_ref()
.try_into()
.map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?,
);
let index_data_bytes: [u8; 8] = hint_data[32..40]
.try_into()
.map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?;
let timestamp_data_bytes: [u8; 8] = hint_data[40..48]
.try_into()
.map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?;

let hash: B256 = hash_data_bytes.into();
let index = u64::from_be_bytes(index_data_bytes);
let timestamp = u64::from_be_bytes(timestamp_data_bytes);

let partial_block_ref = BlockInfo { timestamp, ..Default::default() };
let indexed_hash = IndexedBlobHash { index: index as usize, hash };
Expand Down

0 comments on commit 44146a5

Please sign in to comment.