fn update_hash(&mut self, index: HashIndex) -> Hash {
        // should NEVER be used to update the leaf hash

        // print!("Updating index {}, {}\n", index.0, index.1);

        assert!(index.0 < self.tree_depth);
        assert!(index.1 < self.capacity());

        // Indices for child nodes in the tree: one hight up, and (x2) and (x2 + 1) indices
        // at the layer.
        let lhs_index = (index.0 + 1, (index.1 << 1));
        let rhs_index = (index.0 + 1, (index.1 << 1) + 1);

        let lhs_hash = self.get_hash(lhs_index);
        let rhs_hash = self.get_hash(rhs_index);

        //let idx = (1 << index.0) + index.1;
        //debug!("({:?}, {:?}, {})", &lhs_hash, &rhs_hash, (self.tree_depth - 1 - index.0));

        let hash = self.hasher.compress(
            &lhs_hash,
            &rhs_hash,
            (self.tree_depth - 1 - index.0) as usize,
        );

        //debug!("hash [{}] = {:?}", (1 << index.0) + index.1, hash);

        self.hashes.insert(index.pack(), hash.clone());
        hash
    }
/// Calculates the hash of the non-bottom layer by aggregating two
/// bottom-laying hashes. For layer 1 and hash index 0, the hashes
/// 0 and 1 of layer 2 are aggregated.
Calculates the hash of the non-bottom layer by aggregating two
bottom-laying hashes. For layer 1 and hash index 0, the hashes
0 and 1 of layer 2 are aggregated.
Calculates the hash of the non - bottom layer by aggregating two bottom - laying hashes . For layer 1 and hash index 0 the hashes 0 and 1 of layer 2 are aggregated .
fn update_hash(&mut self, index: HashIndex) -> Hash {
        // should NEVER be used to update the leaf hash
        // print!("Updating index {}, {}\n", index.0, index.1);
        assert!(index.0 < self.tree_depth);
        assert!(index.1 < self.capacity());
        // Indices for child nodes in the tree: one hight up, and (x2) and (x2 + 1) indices
        // at the layer.
        let lhs_index = (index.0 + 1, (index.1 << 1));
        let rhs_index = (index.0 + 1, (index.1 << 1) + 1);
        let lhs_hash = self.get_hash(lhs_index);
        let rhs_hash = self.get_hash(rhs_index);
        //let idx = (1 << index.0) + index.1;
        //debug!("({:?}, {:?}, {})", &lhs_hash, &rhs_hash, (self.tree_depth - 1 - index.0));
        let hash = self.hasher.compress(
            &lhs_hash,
            &rhs_hash,
            (self.tree_depth - 1 - index.0) as usize,
        );
        //debug!("hash [{}] = {:?}", (1 << index.0) + index.1, hash);
        self.hashes.insert(index.pack(), hash.clone());
        hash
    }
fn update_hash ( & mut self , index : HashIndex ) -> Hash { // should NEVER be used to update the leaf hash // print!("Updating index {}, {}\n", index.0, index.1); assert ! ( index 0 self tree_depth ) ; assert ! ( index 1 self capacity ( ) ) ; // Indices for child nodes in the tree: one hight up, and (x2) and (x2 + 1) indices // at the layer. let lhs_index = ( index . 0 + 1 , ( index . 1 << 1 ) ) ; let rhs_index = ( index . 0 + 1 , ( index . 1 << 1 ) + 1 ) ; let lhs_hash = self . get_hash ( lhs_index ) ; let rhs_hash = self . get_hash ( rhs_index ) ; //let idx = (1 << index.0) + index.1; //debug!("({:?}, {:?}, {})", &lhs_hash, &rhs_hash, (self.tree_depth - 1 - index.0)); let hash = self . hasher . compress ( & lhs_hash , & rhs_hash , ( self . tree_depth - 1 - index . 0 ) as usize , ) ; //debug!("hash [{}] = {:?}", (1 << index.0) + index.1, hash); self . hashes . insert ( index . pack ( ) , hash . clone ( ) ) ; hash }
Calculates the hash of the non-bottom layer by aggregating two
bottom-laying hashes.
Calculates the hash of the non - bottom layer by aggregating two bottom - laying hashes .
&mut self
index
HashIndex