Skip to content

Commit

Permalink
Apply suggestions from code review.
Browse files Browse the repository at this point in the history
Co-authored-by: str4d <[email protected]>
  • Loading branch information
nuttycom and str4d authored Jan 19, 2024
1 parent 34b1a5f commit 2f17533
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions shardtree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,37 @@ impl<

/// Adds the provided checkpoint to the set of checkpoints to be retained
/// across pruning operations.
///
/// TODO: A bit more documentation.
///
/// # Examples
///
/// ```
/// use incrementalmerkletree::Retention;
/// use shardtree::ShardTree;
///
/// # fn load_shardtree_from_disk() -> ShardTree<SomeShardStore> {
/// # todo!("Kris returns something useful for testing here.")
/// # }
/// # fn checkpoints_to_retain() -> Vec<SomeCheckpointId> {
/// # vec![] // TODO: Return something useful for testing here.
/// # }
/// # fn get_next_leaf() -> SomeLeafType {
/// # todo!("Kris returns something useful for testing here.")
/// # }
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut tree = load_shardtree_from_disk();
///
/// // The required checkpoints are stored separately from the tree.
/// for checkpoint_id in checkpoints_to_retain() {
/// tree.ensure_retained(checkpoint_id);
/// }
///
/// // Now perform operations that might prune the tree.
/// tree.append(get_next_leaf(), Retention::Ephemeral)?;
/// # Ok(())
/// # }
/// ```
pub fn ensure_retained(&mut self, checkpoint_id: C) {
self.to_retain.insert(checkpoint_id);
}
Expand Down

0 comments on commit 2f17533

Please sign in to comment.