mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
perf(trie): use sequential hashing in BlockchainProvider::hashed_post_state (#22660)
Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
@@ -46,33 +46,6 @@ impl HashedPostState {
|
||||
/// Hashes all changed accounts and storage entries that are currently stored in the bundle
|
||||
/// state.
|
||||
#[inline]
|
||||
#[cfg(feature = "rayon")]
|
||||
pub fn from_bundle_state<'a, KH: KeyHasher>(
|
||||
state: impl IntoParallelIterator<Item = (&'a Address, &'a BundleAccount)>,
|
||||
) -> Self {
|
||||
state
|
||||
.into_par_iter()
|
||||
.map(|(address, account)| {
|
||||
let hashed_address = KH::hash_key(address);
|
||||
let hashed_account = account.info.as_ref().map(Into::into);
|
||||
let hashed_storage = HashedStorage::from_plain_storage(
|
||||
account.status,
|
||||
account.storage.iter().map(|(slot, value)| (slot, &value.present_value)),
|
||||
);
|
||||
|
||||
(
|
||||
hashed_address,
|
||||
hashed_account,
|
||||
(!hashed_storage.is_empty()).then_some(hashed_storage),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Initialize [`HashedPostState`] from bundle state.
|
||||
/// Hashes all changed accounts and storage entries that are currently stored in the bundle
|
||||
/// state.
|
||||
#[cfg(not(feature = "rayon"))]
|
||||
pub fn from_bundle_state<'a, KH: KeyHasher>(
|
||||
state: impl IntoIterator<Item = (&'a Address, &'a BundleAccount)>,
|
||||
) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user