EthTrie

Struct EthTrie 

Source
pub struct EthTrie<D>
where D: DB,
{ pub db: Arc<D>, /* private fields */ }

Fields§

§db: Arc<D>

Implementations§

Source§

impl<D> EthTrie<D>
where D: DB,

Source

pub fn iter(&self) -> TrieIterator<'_, D>

Source

pub fn new(db: Arc<D>) -> Self

Source

pub fn from(db: Arc<D>, root: B256) -> Result<Self, TrieError>

Trait Implementations§

Source§

impl<D> Debug for EthTrie<D>
where D: DB + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D> Trie<D> for EthTrie<D>
where D: DB,

Source§

fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, TrieError>

Returns the value for key stored in the trie.

Source§

fn contains(&self, key: &[u8]) -> Result<bool, TrieError>

Checks that the key is present in the trie

Source§

fn insert(&mut self, key: &[u8], value: &[u8]) -> Result<(), TrieError>

Inserts value into trie and modifies it if it exists

Source§

fn remove(&mut self, key: &[u8]) -> Result<bool, TrieError>

Removes any existing value for key from the trie.

Source§

fn root_hash(&mut self) -> Result<B256, TrieError>

Saves all the nodes in the db, clears the cache data, recalculates the root. Returns the root hash of the trie.

Source§

fn root_hash_with_changed_nodes( &mut self, ) -> Result<RootWithTrieDiff, TrieError>

Saves all the nodes in the db, clears the cache data, recalculates the root. Returns the root hash of the trie and updated nodes from the cache.

Source§

fn clear_trie_from_db(&mut self) -> Result<(), TrieError>

Clears the whole trie from the database.

Source§

fn get_proof(&mut self, key: &[u8]) -> Result<Vec<Vec<u8>>, TrieError>

Prove constructs a merkle proof for key. The result contains all encoded nodes on the path to the value at key. The value itself is also included in the last node and can be retrieved by verifying the proof.

If the trie does not contain a value for key, the returned proof contains all nodes of the longest existing prefix of the key (at least the root node), ending with the node that proves the absence of the key.

Source§

fn verify_proof( &self, root_hash: B256, key: &[u8], proof: Vec<Vec<u8>>, ) -> Result<Option<Vec<u8>>, TrieError>

return value if key exists, None if key not exist, Error if proof is wrong

Auto Trait Implementations§

§

impl<D> Freeze for EthTrie<D>

§

impl<D> RefUnwindSafe for EthTrie<D>
where D: RefUnwindSafe,

§

impl<D> Send for EthTrie<D>

§

impl<D> Sync for EthTrie<D>

§

impl<D> Unpin for EthTrie<D>

§

impl<D> UnwindSafe for EthTrie<D>
where D: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.