Skip to content

Commit 93006af

Browse files
author
Beau Shinkle
committed
Clarify how branches indexing works
1 parent 5099eeb commit 93006af

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

contracts/SortitionTree.sol

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ contract SortitionTree {
3636
// level7 2M
3737
uint256 internal root;
3838

39-
// A mapping from layer => (index => branch). For example, to access the 6th
40-
// (0-index) branch in the 2nd layer (right below the root node), call
41-
// branches[2][6]. Mappings are used in place of arrays for efficiency.
39+
// A 2-index mapping from layer => (index (0-index) => branch). For example,
40+
// to access the 6th branch in the 2nd layer (right below the root node; the
41+
// first branch layer), call branches[2][5]. Mappings are used in place of
42+
// arrays for efficiency. The root is the first layer, the branches occupy
43+
// layers 2 through 7, and layer 8 is for the leaves. Following this
44+
// convention, the first index in `branches` is `2`, and the last index is
45+
// `7`.
4246
mapping(uint256 => mapping(uint256 => uint256)) internal branches;
4347

4448
// A 0-index mapping from index => leaf, acting as an array. For example, to

0 commit comments

Comments
 (0)