Struct grovedb_merk::tree::RefWalker
source · pub struct RefWalker<'a, S>{ /* private fields */ }Expand description
Allows read-only traversal of a Tree, fetching from the given source when
traversing to a pruned node. The fetched nodes are then retained in memory
until they (possibly) get pruned on the next commit.
Only finalized trees may be walked (trees which have had commit called
since the last update).
Implementations§
source§impl<'a, S> RefWalker<'a, S>
impl<'a, S> RefWalker<'a, S>
sourcepub fn create_chunk(
&mut self,
depth: usize,
grove_version: &GroveVersion,
) -> Result<Vec<Op>, Error>
pub fn create_chunk( &mut self, depth: usize, grove_version: &GroveVersion, ) -> Result<Vec<Op>, Error>
Returns a chunk of a given depth from a RefWalker
sourcepub fn traverse_and_build_chunk(
&mut self,
instructions: &[bool],
depth: usize,
grove_version: &GroveVersion,
) -> Result<Vec<Op>, Error>
pub fn traverse_and_build_chunk( &mut self, instructions: &[bool], depth: usize, grove_version: &GroveVersion, ) -> Result<Vec<Op>, Error>
Returns a chunk of a given depth after applying some traversal instruction to the RefWalker
sourcepub fn generate_height_proof(
&mut self,
proof: &mut Vec<Op>,
grove_version: &GroveVersion,
) -> CostResult<(), Error>
pub fn generate_height_proof( &mut self, proof: &mut Vec<Op>, grove_version: &GroveVersion, ) -> CostResult<(), Error>
Returns the smallest amount of tree ops, that can convince
a verifier of the tree height
the generated subtree is of this form
kv_hash
/
kv_hash node_hash
/
kv_hash node_hash
.
.
.
source§impl<'a, S> RefWalker<'a, S>
impl<'a, S> RefWalker<'a, S>
sourcepub fn new(tree: &'a mut TreeNode, source: S) -> Self
pub fn new(tree: &'a mut TreeNode, source: S) -> Self
Creates a RefWalker with the given tree and source.
sourcepub fn tree(&self) -> &TreeNode
pub fn tree(&self) -> &TreeNode
Gets an immutable reference to the Tree wrapped by this RefWalker.
sourcepub fn walk<V>(
&mut self,
left: bool,
value_defined_cost_fn: Option<&V>,
grove_version: &GroveVersion,
) -> CostResult<Option<RefWalker<'_, S>>, Error>
pub fn walk<V>( &mut self, left: bool, value_defined_cost_fn: Option<&V>, grove_version: &GroveVersion, ) -> CostResult<Option<RefWalker<'_, S>>, Error>
Traverses to the child on the given side (if any), fetching from the
source if pruned. When fetching, the link is upgraded from
Link::Reference to Link::Loaded.
Auto Trait Implementations§
impl<'a, S> Freeze for RefWalker<'a, S>where
S: Freeze,
impl<'a, S> RefUnwindSafe for RefWalker<'a, S>where
S: RefUnwindSafe,
impl<'a, S> Send for RefWalker<'a, S>where
S: Send,
impl<'a, S> Sync for RefWalker<'a, S>where
S: Sync,
impl<'a, S> Unpin for RefWalker<'a, S>where
S: Unpin,
impl<'a, S> !UnwindSafe for RefWalker<'a, S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CostsExt for T
impl<T> CostsExt for T
source§fn wrap_with_cost(self, cost: OperationCost) -> CostContext<Self>where
Self: Sized,
fn wrap_with_cost(self, cost: OperationCost) -> CostContext<Self>where
Self: Sized,
CostContext object with provided costs.source§fn wrap_fn_cost(
self,
f: impl FnOnce(&Self) -> OperationCost,
) -> CostContext<Self>where
Self: Sized,
fn wrap_fn_cost(
self,
f: impl FnOnce(&Self) -> OperationCost,
) -> CostContext<Self>where
Self: Sized,
CostContext object with costs computed using the
value getting wrapped.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more