Skip to content

Commit

Permalink
debug: avoid _be_ fns
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-rise committed Aug 17, 2024
1 parent 295ef07 commit 8c8c4dd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/storage/on_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Storage for OnDiskStorage {

if let Some(bytes) = bytes {
let c = B256::from_slice(&bytes[0..32]);
let b = U256::from_be_slice(&bytes[32..64]);
let b: U256 = B256::from_slice(&bytes[32..64]).into();
let n = B64::from_slice(&bytes[64..]).into();
vacant.insert(Some((c, b, n)));
Ok(Some(AccountBasic {
Expand Down Expand Up @@ -103,7 +103,7 @@ impl Storage for OnDiskStorage {

if let Some(bytes) = bytes {
let c = B256::from_slice(&bytes[0..32]);
let b = U256::from_be_slice(&bytes[32..64]);
let b: U256 = B256::from_slice(&bytes[32..64]).into();
let n = B64::from_slice(&bytes[64..]).into();
vacant.insert(Some((c, b, n)));
Ok(if c == KECCAK_EMPTY { None } else { Some(c) })
Expand Down Expand Up @@ -145,9 +145,11 @@ impl Storage for OnDiskStorage {
Entry::Vacant(vacant) => {
let bytes: Option<[u8; 32]> = self.tx().get(
self.table_storage.dbi(),
&[address.as_slice(), &index.to_be_bytes::<32>()].concat(),
&[address.as_slice(), Into::<B256>::into(*index).as_slice()].concat(),
)?;
let storage_value = bytes.map(U256::from_be_bytes).unwrap_or(U256::ZERO);
let storage_value = bytes
.map(|bytes| B256::new(bytes).into())
.unwrap_or(U256::ZERO);
vacant.insert(storage_value);
Ok(storage_value)
}
Expand All @@ -160,7 +162,7 @@ impl Storage for OnDiskStorage {
Entry::Vacant(vacant) => {
let bytes: Option<[u8; 32]> = self
.tx()
.get(self.table_block_hashes.dbi(), &number.to_be_bytes())?;
.get(self.table_block_hashes.dbi(), B64::from(*number).as_ref())?;
let block_hash = match bytes {
Some(bytes) => B256::from(bytes),
None => keccak256(number.to_string().as_bytes()),
Expand Down

0 comments on commit 8c8c4dd

Please sign in to comment.