pub(super) fn finalize(
        self,
        manifest: Manifest,
        leaf_count: u64,
        operation: Operation,
        hasher: &dyn HashTree,
    ) -> (ValueHash, PatchSet, HashingStats) {
        let mut stats = HashingStats::default();
        let (root_hash, patch) = self.finalize_inner(
            manifest,
            leaf_count,
            operation,
            |nibble_count, level_changes| {
                let started_at = Instant::now();
                let tree_level = nibble_count * 4;
                // `into_par_iter()` below uses `rayon` to parallelize hash computations.
                let output = level_changes
                    .into_par_iter()
                    .map_init(
                        || hasher.with_stats(&stats),
                        |hasher, (nibbles, node)| {
                            let nibbles = Nibbles::from_parts(nibbles, nibble_count);
                            (nibbles, Some(node.inner.hash(hasher, tree_level)), node)
                        },
                    )
                    .collect::<Vec<_>>();
                stats.hashing_duration += started_at.elapsed();
                output
            },
        );
        let root_hash = root_hash.unwrap_or_else(|| hasher.empty_tree_hash());
        (root_hash, patch, stats)
    }
Computes hashes and serializes this change set.
core/lib/merkle_tree/src/storage/patch.rs