reth_trie_sparse/
blinded.rsuse alloy_primitives::{Bytes, B256};
use reth_execution_errors::SparseTrieError;
use reth_trie_common::Nibbles;
pub trait BlindedProviderFactory {
type AccountNodeProvider: BlindedProvider;
type StorageNodeProvider: BlindedProvider;
fn account_node_provider(&self) -> Self::AccountNodeProvider;
fn storage_node_provider(&self, account: B256) -> Self::StorageNodeProvider;
}
pub trait BlindedProvider {
type Error: Into<SparseTrieError>;
fn blinded_node(&mut self, path: &Nibbles) -> Result<Option<Bytes>, Self::Error>;
}
#[derive(PartialEq, Eq, Clone, Default, Debug)]
pub struct DefaultBlindedProviderFactory;
impl BlindedProviderFactory for DefaultBlindedProviderFactory {
type AccountNodeProvider = DefaultBlindedProvider;
type StorageNodeProvider = DefaultBlindedProvider;
fn account_node_provider(&self) -> Self::AccountNodeProvider {
DefaultBlindedProvider
}
fn storage_node_provider(&self, _account: B256) -> Self::StorageNodeProvider {
DefaultBlindedProvider
}
}
#[derive(PartialEq, Eq, Clone, Default, Debug)]
pub struct DefaultBlindedProvider;
impl BlindedProvider for DefaultBlindedProvider {
type Error = SparseTrieError;
fn blinded_node(&mut self, _path: &Nibbles) -> Result<Option<Bytes>, Self::Error> {
Ok(None)
}
}
#[inline]
pub fn pad_path_to_key(path: &Nibbles) -> B256 {
let mut padded = path.pack();
padded.resize(32, 0);
B256::from_slice(&padded)
}