reth_trie_parallel/
storage_root_targets.rs
1use alloy_primitives::{map::B256Map, B256};
2use derive_more::{Deref, DerefMut};
3use reth_trie::prefix_set::PrefixSet;
4
5#[derive(Deref, DerefMut, Debug)]
7pub struct StorageRootTargets(B256Map<PrefixSet>);
8
9impl StorageRootTargets {
10 pub fn new(
16 changed_accounts: impl IntoIterator<Item = B256>,
17 storage_prefix_sets: impl IntoIterator<Item = (B256, PrefixSet)>,
18 ) -> Self {
19 Self(
20 changed_accounts
21 .into_iter()
22 .map(|address| (address, PrefixSet::default()))
23 .chain(storage_prefix_sets)
24 .collect(),
25 )
26 }
27}
28
29impl IntoIterator for StorageRootTargets {
30 type Item = (B256, PrefixSet);
31 type IntoIter = std::collections::hash_map::IntoIter<B256, PrefixSet>;
32
33 fn into_iter(self) -> Self::IntoIter {
34 self.0.into_iter()
35 }
36}
37
38impl rayon::iter::IntoParallelIterator for StorageRootTargets {
39 type Iter = rayon::collections::hash_map::IntoIter<B256, PrefixSet>;
40 type Item = (B256, PrefixSet);
41
42 fn into_par_iter(self) -> Self::Iter {
43 self.0.into_par_iter()
44 }
45}