jmt::storage

Trait TreeReader

Source
pub trait TreeReader {
    // Required methods
    fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>>;
    fn get_value_option(
        &self,
        max_version: Version,
        key_hash: KeyHash,
    ) -> Result<Option<OwnedValue>>;
    fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>>;

    // Provided methods
    fn get_node(&self, node_key: &NodeKey) -> Result<Node> { ... }
    fn get_value(
        &self,
        max_version: Version,
        key_hash: KeyHash,
    ) -> Result<OwnedValue> { ... }
}
Expand description

Defines the interface between a JellyfishMerkleTree and underlying storage holding nodes.

Required Methods§

Source

fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>>

Gets node given a node key. Returns None if the node does not exist.

Source

fn get_value_option( &self, max_version: Version, key_hash: KeyHash, ) -> Result<Option<OwnedValue>>

Gets a value by identifier, returning the newest value whose version is less than or equal to the specified version. Returns None if the value does not exist.

Source

fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>>

Gets the rightmost leaf. Note that this assumes we are in the process of restoring the tree and all nodes are at the same version.

Provided Methods§

Source

fn get_node(&self, node_key: &NodeKey) -> Result<Node>

Gets node given a node key. Returns error if the node does not exist.

Source

fn get_value( &self, max_version: Version, key_hash: KeyHash, ) -> Result<OwnedValue>

Gets a value by identifier, returning the newest value whose version is less than or equal to the specified version. Returns an error if the value does not exist.

Implementors§