Trait TreeReader
pub trait TreeReader {
// Required methods
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>, Error>;
fn get_value_option(
&self,
max_version: u64,
key_hash: KeyHash,
) -> Result<Option<Vec<u8>>, Error>;
fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>, Error>;
// Provided methods
fn get_node(&self, node_key: &NodeKey) -> Result<Node, Error> { ... }
fn get_value(
&self,
max_version: u64,
key_hash: KeyHash,
) -> Result<Vec<u8>, Error> { ... }
}Expand description
Defines the interface between a
JellyfishMerkleTree
and underlying storage holding nodes.
Required Methods§
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>, Error>
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>, Error>
Gets node given a node key. Returns None if the node does not exist.
fn get_value_option(
&self,
max_version: u64,
key_hash: KeyHash,
) -> Result<Option<Vec<u8>>, Error>
fn get_value_option( &self, max_version: u64, key_hash: KeyHash, ) -> Result<Option<Vec<u8>>, Error>
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.
fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>, Error>
fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>, Error>
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.