Skip to content
Merged
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
30 changes: 16 additions & 14 deletions crates/optimism/trie/src/db/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,22 +308,24 @@ where
}

fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
let result = self.inner.next().map(|opt| {
opt.and_then(|(k, v)| {
// Only return entries that belong to the bound address
(k.hashed_address == self.hashed_address).then_some((k.hashed_storage_key, v.0))
})
})?;
loop {
let result = self.inner.next().map(|opt| {
opt.and_then(|(k, v)| {
// Only return entries that belong to the bound address
(k.hashed_address == self.hashed_address).then_some((k.hashed_storage_key, v.0))
})
})?;

// hashed storage values can be zero, which means the storage slot is deleted, so we
// should skip those
if let Some((_, v)) = result &&
v.is_zero()
{
continue;
}

// hashed storage values can be zero, which means the storage slot is deleted, so we should
// skip those
if let Some((_, v)) = result &&
v.is_zero()
{
return self.next();
return Ok(result);
}

Ok(result)
}

fn reset(&mut self) {
Expand Down
Loading