Skip to content

Instantly share code, notes, and snippets.

@dangerousfood
Created June 11, 2019 19:18
Show Gist options
  • Save dangerousfood/56ebd27dbf1124bdaf8bc9018affdf5a to your computer and use it in GitHub Desktop.
Save dangerousfood/56ebd27dbf1124bdaf8bc9018affdf5a to your computer and use it in GitHub Desktop.
private void calcBranches() {
for (int i = 0; i < height; i++) {
List<Bytes32> parent = tree.get(i + 1);
List<Bytes32> child = tree.get(i);
for (int j = 0; j < child.size(); j += 2) {
Bytes32 leftNode = child.get(j);
Bytes32 rightNode = (j + 1 < child.size()) ? child.get(j + 1) : zeroHashes.get(i);
parent.add(j / 2, Hash.sha2_256(Bytes.concatenate(leftNode, rightNode)));
}
}
dirty = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment