Skip to content

Commit

Permalink
wipe storage cache
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Oct 21, 2024
1 parent 68834e9 commit be922b0
Showing 1 changed file with 12 additions and 35 deletions.
47 changes: 12 additions & 35 deletions crates/storage/provider/src/providers/state/cache/cache_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,44 +77,21 @@ impl<'a, TX> PlainCacheWriter<'a, TX> {
}
}

let cursor = self.0.cursor_dup_read::<tables::PlainStorageState>();
match cursor {
Ok(mut cursor) => {
// Update storage cache
for storage in &change_set.storage {
if storage.wipe_storage {
let walker = cursor.walk_dup(Some(storage.address), None);
match walker {
Ok(walker) => {
for kv in walker {
match kv {
Ok((k, v)) => {
super::plain_state::PLAIN_STORAGES.remove(&(k, v.key));
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();
break;
}
}
}
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();
break;
}
}
}

for (k, v) in storage.storage.clone() {
super::plain_state::PLAIN_STORAGES
.insert((storage.address, StorageKey::from(k)), v);
}
}
let mut should_wipe = false;
for storage in &change_set.storage {
if storage.wipe_storage {
should_wipe = true;
break;
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();

for (k, v) in storage.storage.clone() {
super::plain_state::PLAIN_STORAGES
.insert((storage.address, StorageKey::from(k)), v);
}
}
if should_wipe {
super::plain_state::PLAIN_STORAGES.clear();
}
}
}

Expand Down

0 comments on commit be922b0

Please sign in to comment.