File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ library TreeCbor {
1414 }
1515
1616 function _readTree (bytes [] memory cborData ) internal pure returns (Tree memory ) {
17+ require (cborData.length > 0 , "Tree must contain nodes " );
1718 TreeNodeCbor.TreeNode[] memory nodes = new TreeNodeCbor.TreeNode [](cborData.length );
1819 CidCbor.CidBytes32[] memory cids = new CidCbor.CidBytes32 [](cborData.length );
1920
@@ -28,7 +29,7 @@ library TreeCbor {
2829 }
2930
3031 function readTree (bytes [] memory cborData ) internal pure returns (Tree memory ) {
31- return requireUniqueCids (_readTree (cborData));
32+ return validTree (_readTree (cborData));
3233 }
3334
3435 function getCid (Tree memory tree , CidCbor.CidBytes32 indexCid )
@@ -53,7 +54,7 @@ library TreeCbor {
5354 revert ("node not found " );
5455 }
5556
56- function requireUniqueCids (Tree memory tree ) internal pure returns (Tree memory ) {
57+ function validTree (Tree memory tree ) internal pure returns (Tree memory ) {
5758 for (uint i = 0 ; i < tree.cids.length ; i++ ) {
5859 bytes32 thisCid = CidCbor.CidBytes32.unwrap (tree.cids[i]);
5960 for (uint j = i + 1 ; j < tree.nodes.length ; j++ ) {
You can’t perform that action at this time.
0 commit comments