Struct cita_trie::PatriciaTrie

source ·
pub struct PatriciaTrie<D, H>where
    D: DB,
    H: Hasher,{ /* private fields */ }

Implementations§

source§

impl<D, H> PatriciaTrie<D, H>where D: DB, H: Hasher,

source

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

source

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

source

pub fn from(db: Arc<D>, hasher: Arc<H>, root: &[u8]) -> Result<Self, TrieError>

source

pub fn extract_backup( db: Arc<D>, backup_db: Option<Arc<D>>, hasher: Arc<H>, root_hash: &[u8] ) -> Result<(Self, Vec<Vec<u8>>), TrieError>

Trait Implementations§

source§

impl<D, H> Debug for PatriciaTrie<D, H>where D: DB + Debug, H: Hasher + Debug,

source§

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

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

impl<D, H> Trie<D, H> for PatriciaTrie<D, H>where D: DB, H: Hasher,

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: Vec<u8>, value: Vec<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(&mut self) -> Result<Vec<u8>, TrieError>

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

source§

fn get_proof(&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: &[u8], 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, H> !RefUnwindSafe for PatriciaTrie<D, H>

§

impl<D, H> !Send for PatriciaTrie<D, H>

§

impl<D, H> !Sync for PatriciaTrie<D, H>

§

impl<D, H> Unpin for PatriciaTrie<D, H>

§

impl<D, H> !UnwindSafe for PatriciaTrie<D, H>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.