diff --git a/accounts-db/src/accounts_hash.rs b/accounts-db/src/accounts_hash.rs index 30b387148..c9fb1aae2 100644 --- a/accounts-db/src/accounts_hash.rs +++ b/accounts-db/src/accounts_hash.rs @@ -42,12 +42,9 @@ impl MmapAccountHashesFile { /// return a slice of account hashes starting at 'index' fn read(&self, index: usize) -> &[Hash] { let start = std::mem::size_of::() * index; - let item_slice: &[u8] = &self.mmap[start..self.count * std::mem::size_of::()]; - let remaining_elements = item_slice.len() / std::mem::size_of::(); - unsafe { - let item = item_slice.as_ptr() as *const Hash; - std::slice::from_raw_parts(item, remaining_elements) - } + let end = std::mem::size_of::() * self.count; + let bytes = &self.mmap[start..end]; + bytemuck::cast_slice(bytes) } /// write a hash to the end of mmap file.