Skip to content

Commit

Permalink
feat: add changed storage slots iter (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 16, 2023
1 parent 68f78ae commit c593653
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions crates/primitives/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ impl Default for AccountStatus {
}

impl Account {
/// Create new account and mark it as non existing.
pub fn new_not_existing() -> Self {
Self {
info: AccountInfo::default(),
storage: HashMap::new(),
status: AccountStatus::LoadedAsNotExisting,
}
}

/// Mark account as self destructed.
pub fn mark_selfdestruct(&mut self) {
self.status |= AccountStatus::SelfDestructed;
Expand Down Expand Up @@ -109,13 +118,11 @@ impl Account {
self.info.is_empty()
}

/// Create new account and mark it as non existing.
pub fn new_not_existing() -> Self {
Self {
info: AccountInfo::default(),
storage: HashMap::new(),
status: AccountStatus::LoadedAsNotExisting,
}
/// Returns an iterator over the storage slots that have been changed.
///
/// See also [StorageSlot::is_changed]
pub fn changed_storage_slots(&self) -> impl Iterator<Item = (&U256, &StorageSlot)> {
self.storage.iter().filter(|(_, slot)| slot.is_changed())
}
}

Expand Down

0 comments on commit c593653

Please sign in to comment.