Struct tree_index::TreeIndex
[−]
[src]
pub struct TreeIndex { /* fields omitted */ }
Index a tree structure or something.
Methods
impl TreeIndex
[src]
pub fn new(bitfield: Bitfield) -> Self
[src]
Create a new TreeIndex by passing it a sparse_bitfield instance.
pub fn get(&mut self, index: usize) -> bool
[src]
Get a bit from the bitfield.
pub fn set(&mut self, index: usize) -> Change
[src]
Set an index on the tree to true
, and also all of the parents to the
index. Walks the tree upward.
Returns a "Change" member to indicate if the underlying value was changed.
NOTE: we can probably change the bitfield.set syntax to return false to simplify this code a little.
pub fn proof(&mut self, index: usize, nodes: Vec<usize>) -> Option<Proof>
[src]
Determine which Nodes prove the correctness for the Node at index
.
pub fn digest(&self)
[src]
Create a digest for data at index.
pub fn blocks(&mut self) -> usize
[src]
Get the position of the highest entry in the tree. Aka max.
NOTE: should we rename this to .len()
?
pub fn roots(&mut self, roots: &mut Vec<usize>)
[src]
Get all root nodes.
TODO: don't make this allocate, but fill a vector instead.
pub fn verified_by(&mut self, index: usize) -> Verification
[src]
Find the node that verified the node that's passed.
This is different from the Javascript implementation in that it doesn't
push the top
value into an array, but returns it instead through the
Verification
type.
Trait Implementations
impl Default for TreeIndex
[src]
Create a TreeIndex with an empty sparse_bitfield instance with a page size
of 1024
.