mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(storage): non-optional committed chain in CanonStateNotification (#7566)
This commit is contained in:
@ -194,23 +194,22 @@ where
|
||||
}
|
||||
|
||||
fn on_new_state(&mut self, new_state: CanonStateNotification) {
|
||||
if let Some(committed) = new_state.committed() {
|
||||
let mut cached = CachedReads::default();
|
||||
let mut cached = CachedReads::default();
|
||||
|
||||
// extract the state from the notification and put it into the cache
|
||||
let new_state = committed.state();
|
||||
for (addr, acc) in new_state.bundle_accounts_iter() {
|
||||
if let Some(info) = acc.info.clone() {
|
||||
// we want pre cache existing accounts and their storage
|
||||
// this only includes changed accounts and storage but is better than nothing
|
||||
let storage =
|
||||
acc.storage.iter().map(|(key, slot)| (*key, slot.present_value)).collect();
|
||||
cached.insert_account(addr, info, storage);
|
||||
}
|
||||
// extract the state from the notification and put it into the cache
|
||||
let committed = new_state.committed();
|
||||
let new_state = committed.state();
|
||||
for (addr, acc) in new_state.bundle_accounts_iter() {
|
||||
if let Some(info) = acc.info.clone() {
|
||||
// we want pre cache existing accounts and their storage
|
||||
// this only includes changed accounts and storage but is better than nothing
|
||||
let storage =
|
||||
acc.storage.iter().map(|(key, slot)| (*key, slot.present_value)).collect();
|
||||
cached.insert_account(addr, info, storage);
|
||||
}
|
||||
|
||||
self.pre_cached = Some(PrecachedState { block: committed.tip().hash(), cached });
|
||||
}
|
||||
|
||||
self.pre_cached = Some(PrecachedState { block: committed.tip().hash(), cached });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user