Skip to content

Commit

Permalink
Merge pull request #71 from nuttycom/shardstore_return_owned_types
Browse files Browse the repository at this point in the history
Improvements required for implementing `ShardStore` atop a persistent store.
  • Loading branch information
nuttycom authored May 22, 2023
2 parents 1562397 + 5691b70 commit a26844a
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 158 deletions.
4 changes: 2 additions & 2 deletions bridgetree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ mod tests {
BridgeTree::current_position(self)
}

fn get_marked_leaf(&self, position: Position) -> Option<&H> {
BridgeTree::get_marked_leaf(self, position)
fn get_marked_leaf(&self, position: Position) -> Option<H> {
BridgeTree::get_marked_leaf(self, position).cloned()
}

fn marked_positions(&self) -> BTreeSet<Position> {
Expand Down
4 changes: 2 additions & 2 deletions incrementalmerkletree/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait Tree<H, C> {

/// Returns the leaf at the specified position if the tree can produce
/// a witness for it.
fn get_marked_leaf(&self, position: Position) -> Option<&H>;
fn get_marked_leaf(&self, position: Position) -> Option<H>;

/// Return a set of all the positions for which we have marked.
fn marked_positions(&self) -> BTreeSet<Position>;
Expand Down Expand Up @@ -420,7 +420,7 @@ impl<H: Hashable + Ord + Clone + Debug, C: Clone, I: Tree<H, C>, E: Tree<H, C>>
a
}

fn get_marked_leaf(&self, position: Position) -> Option<&H> {
fn get_marked_leaf(&self, position: Position) -> Option<H> {
let a = self.inefficient.get_marked_leaf(position);
let b = self.efficient.get_marked_leaf(position);
assert_eq!(a, b);
Expand Down
4 changes: 2 additions & 2 deletions incrementalmerkletree/src/testing/complete_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ impl<H: Hashable + PartialEq + Clone, C: Ord + Clone + core::fmt::Debug, const D
self.marks.clone()
}

fn get_marked_leaf(&self, position: Position) -> Option<&H> {
fn get_marked_leaf(&self, position: Position) -> Option<H> {
if self.marks.contains(&position) {
self.leaves
.get(usize::try_from(position).expect(MAX_COMPLETE_SIZE_ERROR))
.and_then(|opt: &Option<H>| opt.as_ref())
.and_then(|opt: &Option<H>| opt.clone())
} else {
None
}
Expand Down
Loading

0 comments on commit a26844a

Please sign in to comment.