pub struct PartialTree<T: Hasher> { /* private fields */ }
Expand description

Partial tree represents a part of the original tree that is enough to calculate the root. Used in to extract the root in a merkle proof, to apply diff to a tree or to merge multiple trees into one.

It is a rare case when you need to use this struct on it’s own. It’s mostly used inside MerkleTree and MerkleProof

Implementations

Takes leaves (item hashes) as an argument and build a Merkle Tree from them. Since it’s a partial tree, hashes must be accompanied by their index in the original tree.

This is a helper function to build a full tree from a full set of leaves without any helper indices

Returns how many layers there is between leaves and the root

Return the root of the tree

Consumes other partial tree into itself, replacing any conflicting nodes with nodes from other in the process. Doesn’t rehash the nodes, so the integrity of the result is not verified. It gives an advantage in speed, but should be used only if the integrity of the tree can’t be broken, for example, it is used in the .commit method of the MerkleTree, since both partial trees are essentially constructed in place and there’s no need to verify integrity of the result.

Returns partial tree layers

Clears all elements in the ree

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

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.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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.