From eb75bab81b34a975f4a197188d53f5cc9e0799c2 Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 15 Jul 2019 18:33:46 +0300 Subject: [PATCH] other way to lookup a root --- contracts/MerkleTreeWithHistory.sol | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contracts/MerkleTreeWithHistory.sol b/contracts/MerkleTreeWithHistory.sol index 587d3aa..28aedbe 100644 --- a/contracts/MerkleTreeWithHistory.sol +++ b/contracts/MerkleTreeWithHistory.sol @@ -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) {