fn recalculate_hashes(&mut self, index: ItemIndex, item: &T) {
        // Current hash index relates to the last tree layer and has
        // the same index as the tree item.
        let hash_index = (self.tree_depth, index);

        // We calculate a store the item hash in a location described above.
        let hash = self.hasher.hash_bits(item.get_bits_le());
        self.hashes.insert(hash_index.pack(), hash);

        // Now we have to go through all the level up to zero (the root layer)
        // and update hashes that were affected by this item.
        let mut next_level = (hash_index.0, hash_index.1);
        for _ in 0..next_level.0 {
            // The next level is one height closer to zero (which is a root height),
            // and has a two times smaller index (if the original index of the item is 4,
            // then the highest layer hash index is 4, then it's 2, then 1, and then finally it's 0).
            next_level = (next_level.0 - 1, next_level.1 >> 1);
            self.update_hash(next_level);
        }

        // After updating the hash we ensure that we've gone up to the tree rot.
        assert_eq!(next_level.0, 0);
    }
/// Stores the item hash and updates hashes up to the tree root.
Stores the item hash and updates hashes up to the tree root.
Stores the item hash and updates hashes up to the tree root .
fn recalculate_hashes(&mut self, index: ItemIndex, item: &T) {
        // Current hash index relates to the last tree layer and has
        // the same index as the tree item.
        let hash_index = (self.tree_depth, index);
        // We calculate a store the item hash in a location described above.
        let hash = self.hasher.hash_bits(item.get_bits_le());
        self.hashes.insert(hash_index.pack(), hash);
        // Now we have to go through all the level up to zero (the root layer)
        // and update hashes that were affected by this item.
        let mut next_level = (hash_index.0, hash_index.1);
        for _ in 0..next_level.0 {
            // The next level is one height closer to zero (which is a root height),
            // and has a two times smaller index (if the original index of the item is 4,
            // then the highest layer hash index is 4, then it's 2, then 1, and then finally it's 0).
            next_level = (next_level.0 - 1, next_level.1 >> 1);
            self.update_hash(next_level);
        }
        // After updating the hash we ensure that we've gone up to the tree rot.
        assert_eq!(next_level.0, 0);
    }
fn recalculate_hashes ( & mut self , index : ItemIndex , item : & T ) { // Current hash index relates to the last tree layer and has // the same index as the tree item. let hash_index = ( self . tree_depth , index ) ; // We calculate a store the item hash in a location described above. let hash = self . hasher . hash_bits ( item . get_bits_le ( ) ) ; self . hashes . insert ( hash_index . pack ( ) , hash ) ; // Now we have to go through all the level up to zero (the root layer) // and update hashes that were affected by this item. let mut next_level = ( hash_index . 0 , hash_index . 1 ) ; for _ in 0 .. next_level . 0 { // The next level is one height closer to zero (which is a root height), // and has a two times smaller index (if the original index of the item is 4, // then the highest layer hash index is 4, then it's 2, then 1, and then finally it's 0). next_level = ( next_level . 0 - 1 , next_level . 1 >> 1 ) ; self . update_hash ( next_level ) ; } // After updating the hash we ensure that we've gone up to the tree rot. assert_eq ! ( next_level 0 0 ) ; }
Stores the item hash and updates hashes up to the tree root.
Stores the item hash and updates hashes up to the tree root .
&mut self
index
ItemIndex
item
&T