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

Retire pruned cache #3573

Merged
merged 2 commits into from
Feb 23, 2021
Merged

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Feb 23, 2021

Our "prune list" implementation maintains an internal "prune cache".

  • The prune list consists of roots of fully pruned subtrees.
  • The cache contains all pos beneath these roots.
  • We check if a pos was pruned by looking in the cache.

We can improve this without needing to maintain an internal cache.

To check if a pos is pruned we can look for the "next" pruned subtree and check if pos is beneath it.
We only need to consider the "next" subtree due to the append-only PMMR semantics.
If the next subtree does not include pos then we know that no other subtree will either.

return 0;
}
peak_map_height(num - 1).1
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a small optimization inlining only the logic required to get the height.
We don't need to calculate peaks and then throw them away.

@antiochp antiochp merged commit 57f4592 into mimblewimble:master Feb 23, 2021
@antiochp antiochp deleted the retire_pruned_cache branch February 23, 2021 19:34
@antiochp antiochp mentioned this pull request May 6, 2021
bayk added a commit to mwcproject/mwc-node that referenced this pull request Jun 12, 2024
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.

1 participant