pub fn update(&mut self, index: usize, new_leaf: &Vec<u8>) -> Result<(), Error> {
            assert!(index < self.leaf_nodes.len(), "index out of range");
            let (updated_leaf_hash, mut updated_path) = self.updated_path(index, new_leaf)?;
            self.leaf_nodes[index] = updated_leaf_hash;
            let mut curr_index = convert_index_to_last_level(index, self.height);
            for _ in 0..self.height - 1 {
                curr_index = parent(curr_index).unwrap();
                self.non_leaf_nodes[curr_index] = updated_path.pop().unwrap();
            }
            Ok(())
        }
/// Update the leaf at `index` to updated leaf.
/// ```tree_diagram
///         [A]
///        /   \
///      [B]    C
///     / \   /  \
///    D [E] F    H
///   .. / \ ....
///    [I] J
/// ```
/// update(3, {new leaf}) would swap the leaf value at `[I]` and cause a recomputation of `[A]`, `[B]`, and `[E]`.
Update the leaf at `index` to updated leaf.
Update the leaf at ` index ` to updated leaf .
pub fn update(&mut self, index: usize, new_leaf: &Vec<u8>) -> Result<(), Error> {
            assert!(index < self.leaf_nodes.len(), "index out of range");
            let (updated_leaf_hash, mut updated_path) = self.updated_path(index, new_leaf)?;
            self.leaf_nodes[index] = updated_leaf_hash;
            let mut curr_index = convert_index_to_last_level(index, self.height);
            for _ in 0..self.height - 1 {
                curr_index = parent(curr_index).unwrap();
                self.non_leaf_nodes[curr_index] = updated_path.pop().unwrap();
            }
            Ok(())
        }
pub fn update ( & mut self , index : usize , new_leaf : & Vec < u8 > ) -> Result < ( ) , Error > { assert ! ( index self leaf_nodes len ( ) " " ) ; let ( updated_leaf_hash , mut updated_path ) = self . updated_path ( index , new_leaf ) ? ; self . leaf_nodes [ index ] = updated_leaf_hash ; let mut curr_index = convert_index_to_last_level ( index , self . height ) ; for _ in 0 .. self . height - 1 { curr_index = parent ( curr_index ) . unwrap ( ) ; self . non_leaf_nodes [ curr_index ] = updated_path . pop ( ) . unwrap ( ) ; } Ok ( ( ) ) }
Update the leaf at `index` to updated leaf.
Update the leaf at ` index ` to updated leaf .
&mut self
index
usize
new_leaf
&Vec<u8>