reth_trie/proof_v2/
metrics.rs1use crate::{
4 hashed_cursor::InstrumentedHashedCursorFactory, trie_cursor::InstrumentedTrieCursorFactory,
5};
6
7#[cfg(feature = "metrics")]
8use crate::{hashed_cursor::HashedCursorMetrics, trie_cursor::TrieCursorMetrics, TrieType};
9
10#[cfg(feature = "metrics")]
12#[derive(Clone, Debug)]
13pub struct ProofCursorMetrics {
14 account_trie_cursor: TrieCursorMetrics,
15 storage_trie_cursor: TrieCursorMetrics,
16 account_hashed_cursor: HashedCursorMetrics,
17 storage_hashed_cursor: HashedCursorMetrics,
18}
19
20#[cfg(feature = "metrics")]
21impl Default for ProofCursorMetrics {
22 fn default() -> Self {
24 Self {
25 account_trie_cursor: TrieCursorMetrics::new(TrieType::State),
26 storage_trie_cursor: TrieCursorMetrics::new(TrieType::Storage),
27 account_hashed_cursor: HashedCursorMetrics::new(TrieType::State),
28 storage_hashed_cursor: HashedCursorMetrics::new(TrieType::Storage),
29 }
30 }
31}
32
33#[cfg(feature = "metrics")]
34impl ProofCursorMetrics {
35 pub fn instrument_trie_factory<F>(&self, factory: F) -> InstrumentedTrieCursorFactory<F> {
37 InstrumentedTrieCursorFactory::new(
38 factory,
39 self.account_trie_cursor.clone(),
40 self.storage_trie_cursor.clone(),
41 )
42 }
43
44 pub fn instrument_hashed_factory<F>(&self, factory: F) -> InstrumentedHashedCursorFactory<F> {
46 InstrumentedHashedCursorFactory::new(
47 factory,
48 self.account_hashed_cursor.clone(),
49 self.storage_hashed_cursor.clone(),
50 )
51 }
52}
53
54#[cfg(not(feature = "metrics"))]
56#[derive(Clone, Debug, Default)]
57pub struct ProofCursorMetrics;
58
59#[cfg(not(feature = "metrics"))]
60impl ProofCursorMetrics {
61 pub const fn instrument_trie_factory<F>(&self, factory: F) -> InstrumentedTrieCursorFactory<F> {
63 factory
64 }
65
66 pub const fn instrument_hashed_factory<F>(
68 &self,
69 factory: F,
70 ) -> InstrumentedHashedCursorFactory<F> {
71 factory
72 }
73}