use derive_more::Deref;
use reth_trie::stats::{TrieStats, TrieTracker};
#[derive(Deref, Clone, Copy, Debug)]
pub struct ParallelTrieStats {
#[deref]
trie: TrieStats,
precomputed_storage_roots: u64,
missed_leaves: u64,
}
impl ParallelTrieStats {
pub const fn trie_stats(&self) -> TrieStats {
self.trie
}
pub const fn precomputed_storage_roots(&self) -> u64 {
self.precomputed_storage_roots
}
pub const fn missed_leaves(&self) -> u64 {
self.missed_leaves
}
}
#[derive(Deref, Default, Debug)]
pub struct ParallelTrieTracker {
#[deref]
trie: TrieTracker,
precomputed_storage_roots: u64,
missed_leaves: u64,
}
impl ParallelTrieTracker {
pub fn set_precomputed_storage_roots(&mut self, count: u64) {
self.precomputed_storage_roots = count;
}
pub fn inc_branch(&mut self) {
self.trie.inc_branch();
}
pub fn inc_leaf(&mut self) {
self.trie.inc_leaf();
}
pub fn inc_missed_leaves(&mut self) {
self.missed_leaves += 1;
}
pub fn finish(self) -> ParallelTrieStats {
ParallelTrieStats {
trie: self.trie.finish(),
precomputed_storage_roots: self.precomputed_storage_roots,
missed_leaves: self.missed_leaves,
}
}
}