Module iterator

Module iterator 

Source
Expand description

Iterators for traversing MMRs of a given size, and functions for computing various MMR properties from their output.

Structs§

PathIterator
A PathIterator returns a (parent_pos, sibling_pos) tuple for the sibling of each node along the path from a given perfect binary tree peak to a designated leaf, not including the peak itself.
PeakIterator
A PeakIterator returns a (position, height) tuple for each peak in an MMR with the given size, in decreasing order of height.

Functions§

leaf_num_to_pos
Returns the position of the leaf with number leaf_num in an MMR.
leaf_pos_to_num
Returns the number of the leaf at position leaf_pos in an MMR, or None if this is not a leaf.
nodes_needing_parents
Returns the set of peaks that will require a new parent after adding the next leaf to an MMR with the given peaks. This set is non-empty only if there is a height-0 (leaf) peak in the MMR. The result will contain this leaf peak plus the other MMR peaks with contiguously increasing height. Nodes in the result are ordered by decreasing height.
pos_to_height
Returns the height of the node at position pos in an MMR.