Commit f5fbed4
committed
refactor!(
This commit introduces type aliases:
- `MerkleTreeNodeIndex` for `u64`
- `MerkleTreeLeafIndex` for `u64`
- `MerkleTreeHeight` for `u32`.
It also refactors `MerkleTree` to avoid using `usize` where-ever
possible, particularly in public functions. Instead, these types
aliases are used.
`MerkleTree` internally stores a `Vec<Digest>`, which induces two
limitations:
1. The index type is `usize`, which complicates matters when
targeting compilation on 32-bit machines (including 32-bit WASM).
2. This vector can store at most 2^25 nodes, whereas we would like
functions associated with Merkle trees to work for Merkle trees
that are far larger (without needing to store all the internal
nodes explicitly).
The second limitation persists. However, the first limitation is fixed
by this commit.
Also, public functions `nodes()` and `leafs()` now return iterators
instead of slices. As these functions were public, this change is
breaking.
Addresses #250.MerkleTree): Use index type aliases1 parent 27a4325 commit f5fbed4
File tree
5 files changed
+134
-80
lines changed- twenty-first
- benches
- src/util_types
- mmr
5 files changed
+134
-80
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
0 commit comments