Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the hash of a PMMR leaf ignoring the leafset #3463

Closed
wants to merge 1 commit into from

Conversation

jaspervdm
Copy link
Contributor

When a leaf is marked for removal (using the leafset), its hash is not actually removed from the backend until its sibling is also removed. The get_hash function on the PMMR will return a None for hashes that are marked for removal but not actually pruned yet. However in this PR we need access to this hash. So here we introduce a new function on the PMMR and Backend that will return a leaf hash, ignoring the leafset.

@jaspervdm jaspervdm requested a review from antiochp October 6, 2020 13:35
Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to do this. We already have get_from_file() on both PMMR and ReadonlyPMMR.

@@ -39,6 +39,9 @@ pub trait Backend<T: PMMRable> {
/// Get a Hash by insertion position.
fn get_hash(&self, position: u64) -> Option<Hash>;

/// Get a leaf hash by insertion position, ignoring the leaf set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary - we already have get_from_file() below, which does exactly this.

@@ -34,6 +34,9 @@ pub trait ReadablePMMR {
/// Get the hash at provided position in the MMR.
fn get_hash(&self, pos: u64) -> Option<Hash>;

/// Get the hash of a leaf, ignoring the leaf set
fn get_leaf_hash(&self, pos: u64) -> Option<Hash>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same - we already have get_from_file() below.

@jaspervdm
Copy link
Contributor Author

Yep, my mistake.

@jaspervdm jaspervdm closed this Oct 6, 2020
@jaspervdm jaspervdm deleted the hash_ignore_leafset branch November 26, 2020 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants