[][src]Struct libra_jellyfish_merkle::JellyfishMerkleTree

pub struct JellyfishMerkleTree<'a, R: 'a + TreeReader> { /* fields omitted */ }

The Jellyfish Merkle tree data structure. See crate for description.

Implementations

impl<'a, R> JellyfishMerkleTree<'a, R> where
    R: 'a + TreeReader
[src]

pub fn new(reader: &'a R) -> Self[src]

Creates a JellyfishMerkleTree backed by the given TreeReader.

pub fn put_blob_set(
    &self,
    blob_set: Vec<(HashValue, AccountStateBlob)>,
    version: Version
) -> Result<(HashValue, TreeUpdateBatch)>
[src]

This is a convenient function that calls put_blob_sets with a single keyed_blob_set.

pub fn put_blob_sets(
    &self,
    blob_sets: Vec<Vec<(HashValue, AccountStateBlob)>>,
    first_version: Version
) -> Result<(Vec<HashValue>, TreeUpdateBatch)>
[src]

Returns the new nodes and account state blobs in a batch after applying blob_set. For example, if after transaction T_i the committed state of tree in the persistent storage looks like the following structure:

             S_i
            /   \
           .     .
          .       .
         /         \
        o           x
       / \
      A   B
       storage (disk)

where A and B denote the states of two adjacent accounts, and x is a sibling subtree of the path from root to A and B in the tree. Then a blob_set produced by the next transaction T_{i+1} modifies other accounts C and D exist in the subtree under x, a new partial tree will be constructed in memory and the structure will be:

                S_i      |      S_{i+1}
               /   \     |     /       \
              .     .    |    .         .
             .       .   |   .           .
            /         \  |  /             \
           /           x | /               x'
          o<-------------+-               / \
         / \             |               C   D
        A   B            |
          storage (disk) |    cache (memory)

With this design, we are able to query the global state in persistent storage and generate the proposed tree delta based on a specific root hash and blob_set. For example, if we want to execute another transaction T_{i+1}', we can use the tree S_i in storage and apply the blob_set of transaction T_{i+1}. Then if the storage commits the returned batch, the state S_{i+1} is ready to be read from the tree by calling get_with_proof. Anything inside the batch is not reachable from public interfaces before being committed.

pub fn get_with_proof(
    &self,
    key: HashValue,
    version: Version
) -> Result<(Option<AccountStateBlob>, SparseMerkleProof)>
[src]

Returns the account state blob (if applicable) and the corresponding merkle proof.

pub fn get_range_proof(
    &self,
    rightmost_key_to_prove: HashValue,
    version: Version
) -> Result<SparseMerkleRangeProof>
[src]

Gets the proof that shows a list of keys up to rightmost_key_to_prove exist at version.

pub fn get_root_hash(&self, version: Version) -> Result<HashValue>[src]

pub fn get_root_hash_option(
    &self,
    version: Version
) -> Result<Option<HashValue>>
[src]

Auto Trait Implementations

impl<'a, R> RefUnwindSafe for JellyfishMerkleTree<'a, R> where
    R: RefUnwindSafe

impl<'a, R> Send for JellyfishMerkleTree<'a, R> where
    R: Sync

impl<'a, R> Sync for JellyfishMerkleTree<'a, R> where
    R: Sync

impl<'a, R> Unpin for JellyfishMerkleTree<'a, R>

impl<'a, R> UnwindSafe for JellyfishMerkleTree<'a, R> where
    R: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,