Lets say that I have a view function that has a loop and that I must use this loop. This loop is calling another view function to verify some data per index key.
The view function is free to execute without getting charged for a GAS.
For example, this works
function retrieve() public pure returns (uint256){
uint256 ret = 0;
for(uint t=0;t<1000;t++){
ret = t;
}
return ret;
}
However, this does not work
function retrieve() public pure returns (uint256){
uint256 ret = 0;
for(uint t=0;t<1000000000000;t++){
ret = t;
}
return ret;
}
}
How many times can I iterate this kind of a loop in a view ? In other words, what is the maximum number between 1000 and 1000000000000 (see the code example above) that I can use and make the loop work ? How is this number determined ?
Edit: I was able to make 15000 iterations on a testnet but not 20000, so I would limit it to just 10000 iterations as a max, assuming it is just calling the index and verifying the value (and use try-catch if possible). Regardless, I still don't know what determines the number, and how it is determined.