-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: provide a safe way to obtain leaf index from mmrIndex (#19)
When the merklebuilder is adding a node it is guaranteed that the before and after mmrIndex are also valid mmrSizes. This lets it use LeafCount to directly obtain the leafIndex of the item just added. This led to the regular use of LeafCount as the way to get the leaf index. It is not safe to do this in general. This change adds FirstMMRSize which returns the size of the smallest valid MMR which containes the node identified by mmrIndex To provide a clear idiom for safely getting the leaf index from a node index (mmrIndex), LeafIndex(mmrIndex) is additionaly provided as a convenience for LeafCount(FirstMMRSize(mmrIndex)) - 1 AB#9551 Co-authored-by: Robin Bryce <[email protected]>
- Loading branch information
1 parent
c09ee35
commit 6bea50d
Showing
4 changed files
with
136 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters