Fix documentation of tree methods.

This commit is contained in:
Kris Nuttycombe 2021-12-01 15:41:33 -07:00
parent 6296748cad
commit 67a5d6ff29
2 changed files with 20 additions and 5 deletions

View File

@ -641,12 +641,19 @@ impl<H: Hashable + Hash + Eq + Debug, const DEPTH: u8> Debug for BridgeTree<H, D
} }
} }
/// An internal-only enum used to indicate whether the `witness_internal`
/// method is being called in the context of marking a leaf as one for
/// which it needs to be able to construct a witness, or whether that
/// leaf is merely being marked as a checkpoint to which it is possible
/// to rewind.
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum BoundaryType { enum BoundaryType {
Witness, Witness,
Checkpoint, Checkpoint,
} }
/// Errors that can appear when validating the internal consistency of a `[MerkleBridge]`
/// value when constructing a bridge from its constituent parts.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum BridgeTreeError { pub enum BridgeTreeError {
IncorrectIncompleteIndex, IncorrectIncompleteIndex,

View File

@ -240,13 +240,21 @@ pub trait Tree<H>: Frontier<H> {
// at which their being spent is is max_checkpoints blocks is the past, // at which their being spent is is max_checkpoints blocks is the past,
// the witness can be discarded. // the witness can be discarded.
/// Marks the current tree state as a checkpoint if it is not already a /// Creates a new checkpoint for the current tree state. It is valid to
/// checkpoint. /// have multiple checkpoints for the same tree state, and each `rewind`
/// call will remove a single checkpoint.
fn checkpoint(&mut self); fn checkpoint(&mut self);
/// Rewinds the tree state to the previous checkpoint. This function will /// Rewinds the tree state to the previous checkpoint, and then removes
/// fail and return false if there is no previous checkpoint or in the event /// that checkpoint record. If there are multiple checkpoints at a given
/// witness data would be destroyed in the process. /// tree state, the tree state will not be altered until all checkpoints
/// at that tree state have been removed using `rewind`. This function
/// will fail and return false if there is no previous checkpoint or in
/// the event witness data would be destroyed in the process.
///
/// In the case that this method returns `false`, the user should have
/// explicitly called `remove_witness` for each witnessed leaf marked
/// since the last checkpoint.
fn rewind(&mut self) -> bool; fn rewind(&mut self) -> bool;
/// Start a recording of append operations performed on a tree. /// Start a recording of append operations performed on a tree.