@@ -33,10 +33,10 @@ library TreeCbor {
3333 }
3434
3535 function hasCid (Tree memory tree , CidCbor.Cid cid ) internal pure returns (bool , uint ) {
36- return hasCid (tree, cid, 0 );
36+ return _hasCid (tree, cid, 0 );
3737 }
3838
39- function hasCid (Tree memory tree , CidCbor.Cid cid , uint startIdx ) internal pure returns (bool , uint ) {
39+ function _hasCid (Tree memory tree , CidCbor.Cid cid , uint startIdx ) internal pure returns (bool , uint ) {
4040 uint256 index = CidCbor.Cid.unwrap (cid);
4141 for (uint i = startIdx; i < tree.cids.length ; i++ ) {
4242 if (CidCbor.Cid.unwrap (tree.cids[i]) == index) {
@@ -99,7 +99,7 @@ library TreeCbor {
9999
100100 while (queue.length > 0 ) {
101101 currentCid = queue[0 ];
102- (hasCurrent, currentIndex) = TreeCbor.hasCid (tree, currentCid, currentIndex );
102+ (hasCurrent, currentIndex) = TreeCbor.hasCid (tree, currentCid);
103103 if (! hasCurrent) {
104104 queue = memPop (queue);
105105 continue ;
@@ -110,12 +110,10 @@ library TreeCbor {
110110
111111 for (uint i = 0 ; i < currentNode.entries.length ; i++ ) {
112112 rightWalk[i] = currentNode.entries[i].tree;
113- if (keccak256 (abi.encode (targetKey)) == keccak256 (abi.encode (currentNode.entries[i].key))) {
114- CidCbor.Cid valueCid = currentNode.entries[i].value;
115- if (CidCbor.Cid.unwrap (valueCid) == CidCbor.Cid.unwrap (targetCid)) {
116- require (! found, "duplicate entry " );
117- found = true ;
118- }
113+ // TODO: match on key lol
114+ if (CidCbor.Cid.unwrap (currentNode.entries[i].value) == CidCbor.Cid.unwrap (targetCid)) {
115+ require (! found, "duplicate entry " );
116+ found = true ;
119117 }
120118 }
121119
0 commit comments