other way to lookup a root

This commit is contained in:
Alexey 2019-07-15 18:33:46 +03:00
parent 5c16e02c90
commit eb75bab81b
1 changed files with 14 additions and 0 deletions

View File

@ -89,12 +89,26 @@ contract MerkleTreeWithHistory {
return true;
}
}
// process the rest of roots
for(i = ROOT_HISTORY_SIZE - 1; i > current_root; i--) {
if (root == _roots[i]) {
return true;
}
}
return false;
// or we can do that in other way
// uint256 i = _current_root;
// do {
// if (root == _roots[i]) {
// return true;
// }
// if (i == 0) {
// i = ROOT_HISTORY_SIZE;
// }
// i--;
// } while (i != _current_root);
}
function getLastRoot() public view returns(uint256) {