Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dangerousfood/b7f94306d5b7ba55d819210aa28ae1e7 to your computer and use it in GitHub Desktop.
Save dangerousfood/b7f94306d5b7ba55d819210aa28ae1e7 to your computer and use it in GitHub Desktop.
public List<Bytes32> getProofTreeByIndex(int index) {
if (dirty) calcBranches();
List<Bytes32> proof = new ArrayList<Bytes32>();
for (int i = 0; i < height; i++) {
index = index % 2 == 1 ? index - 1 : index + 1;
if (index < tree.get(i).size()) proof.add(tree.get(i).get(index));
else proof.add(zeroHashes.get(i));
index /= 2;
}
return proof;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment