pub struct Tree<V: Version> { /* private fields */ }
Expand description

Represents partially loaded tree.

Some kind of “view” into the array representation of the MMR tree. With only some of the leaves/nodes pre-loaded / pre-generated. Exact amount of the loaded data can be calculated by the constructing party, depending on the length of the tree and maximum amount of operations that are going to happen after construction. Tree should not be used as self-contained data structure, since it’s internal state can grow indefinitely after serial operations. Intended use of this Tree is to instantiate it based on partially loaded data (see example how to pick right nodes from the array representation of MMR Tree), perform several operations (append-s/delete-s) and then drop it.

Implementations

Resolve link originated from this tree

New view into the the tree array representation

length is total length of the array representation (is generally not a sum of peaks.len + extra.len) peaks is peaks of the mmr tree extra is some extra nodes that calculated to be required during next one or more operations on the tree.

Panics

Will panic if peaks is empty.

Append one leaf to the tree.

Returns links to actual nodes that has to be persisted as the result of the append. If completed without error, at least one link to the appended node (with metadata provided in new_leaf) will be returned.

Truncate one leaf from the end of the tree.

Returns actual number of nodes that should be removed by the caller from the end of the array representation.

Length of array representation of the tree.

Link to the root node

Reference to the root node.

If this tree is empty.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.