Document state after call to calculate_root_inline

The function call `calculate_root_inline` calculates the merkle root
using the input array as a scratch buffer, i.e., we trash the data
during recursive calls to `merkle_root_r`.

Add explicit documentation to the function so its super clear not to use
the hashes again after calling this function.
This commit is contained in:
Tobin C. Harding 2022-10-29 07:50:09 +11:00
parent 2dbc7fdf21
commit 29df410ea3
1 changed files with 3 additions and 1 deletions

View File

@ -26,7 +26,9 @@ use crate::consensus::encode::Encodable;
/// Calculates the merkle root of a list of *hashes*, inline (in place) in `hashes`. /// Calculates the merkle root of a list of *hashes*, inline (in place) in `hashes`.
/// ///
/// In most cases, you'll want to use [`calculate_root`] instead. /// In most cases, you'll want to use [`calculate_root`] instead. Please note, calling this function
/// trashes the data in `hashes` (i.e. the `hashes` is left in an undefined state at conclusion of
/// this method and should not be used again afterwards).
/// ///
/// # Returns /// # Returns
/// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined. /// - `None` if `hashes` is empty. The merkle root of an empty tree of hashes is undefined.