Skip to content

Commit 2f17533

Browse files
nuttycomstr4d
andauthored
Apply suggestions from code review.
Co-authored-by: str4d <[email protected]>
1 parent 34b1a5f commit 2f17533

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

shardtree/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ impl<
116116

117117
/// Adds the provided checkpoint to the set of checkpoints to be retained
118118
/// across pruning operations.
119+
///
120+
/// TODO: A bit more documentation.
121+
///
122+
/// # Examples
123+
///
124+
/// ```
125+
/// use incrementalmerkletree::Retention;
126+
/// use shardtree::ShardTree;
127+
///
128+
/// # fn load_shardtree_from_disk() -> ShardTree<SomeShardStore> {
129+
/// # todo!("Kris returns something useful for testing here.")
130+
/// # }
131+
/// # fn checkpoints_to_retain() -> Vec<SomeCheckpointId> {
132+
/// # vec![] // TODO: Return something useful for testing here.
133+
/// # }
134+
/// # fn get_next_leaf() -> SomeLeafType {
135+
/// # todo!("Kris returns something useful for testing here.")
136+
/// # }
137+
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
138+
/// let mut tree = load_shardtree_from_disk();
139+
///
140+
/// // The required checkpoints are stored separately from the tree.
141+
/// for checkpoint_id in checkpoints_to_retain() {
142+
/// tree.ensure_retained(checkpoint_id);
143+
/// }
144+
///
145+
/// // Now perform operations that might prune the tree.
146+
/// tree.append(get_next_leaf(), Retention::Ephemeral)?;
147+
/// # Ok(())
148+
/// # }
149+
/// ```
119150
pub fn ensure_retained(&mut self, checkpoint_id: C) {
120151
self.to_retain.insert(checkpoint_id);
121152
}

0 commit comments

Comments
 (0)