function getPosts(address[] subscriptions, uint[] subscriptionIndexes, uint count) public view returns
(address[], bytes32[], bytes32[], uint[]) {
address[] storage postSenders;
bytes32[] storage postLinks;
bytes32[] storage postComments;
uint[] storage postTimestamps;
while(postSenders.length < count) {
(uint postId, address subscription) = getNextPost(subscriptions, subscriptionIndexes);
postSenders.push(subscription);
postLinks.push(addressToLinks[subscription][postId]);
postComments.push(addressToComments[subscription][postId]);
postTimestamps.push(addressToTimestamps[subscription][postId]);
}
return (postSenders, postLinks, postComments, subscriptionIndexes);
}
The above works fine when I pass an array of length 311, but returns this error when I pass an array of length 312 or greater:
Returned error: base fee exceeds gas limit at Object.ErrorResponse
I didn't realize gas was involved when just reading from the blockchain?
I've tried to increase the gas limit like this (using web3. v 1.0):
let results = await myContract.methods.getPosts(subscriptions, indexes, 3).call({gas: 1000000000});
But now I get that error every time regardless of what I put for the gas amount and regardless of how large subscriptions
array is.
Any ideas on how I can make this more efficient or why its failing?
Thanks!