mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
perf(trie): init hashed storage only on existing **changed** slots (#12980)
This commit is contained in:
@ -229,16 +229,20 @@ where
|
||||
let info = if account.is_empty() { None } else { Some(account.info.into()) };
|
||||
hashed_state_update.accounts.insert(hashed_address, info);
|
||||
|
||||
if destroyed || !account.storage.is_empty() {
|
||||
let storage = HashedStorage::from_iter(
|
||||
destroyed,
|
||||
account.storage.into_iter().filter_map(|(slot, value)| {
|
||||
let mut changed_storage_iter = account
|
||||
.storage
|
||||
.into_iter()
|
||||
.filter_map(|(slot, value)| {
|
||||
value
|
||||
.is_changed()
|
||||
.then(|| (keccak256(B256::from(slot)), value.present_value))
|
||||
}),
|
||||
})
|
||||
.peekable();
|
||||
if destroyed || changed_storage_iter.peek().is_some() {
|
||||
hashed_state_update.storages.insert(
|
||||
hashed_address,
|
||||
HashedStorage::from_iter(destroyed, changed_storage_iter),
|
||||
);
|
||||
hashed_state_update.storages.insert(hashed_address, storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user