mivgubel / Solidity-Bootcamp-Week-3-Project

0 stars 0 forks source link

Can this be optimized? #3

Open TechnoGecko opened 2 years ago

TechnoGecko commented 2 years ago

Would it be better to rewrite the ballotContract.proposals function in the contract to do this looping so it only has to write to storage once? It seems like calling this function an indeterminate amount of times could get expensive or lead to us hitting the gas limit

image

TechnoGecko commented 2 years ago

This is from Week 1's code, by the way

mivgubel commented 2 years ago

thanks for your comments Cody!

In this segment, we are just reading the array proposals from the blockchain in the script, so until I know there is no gas cost for this operation.

TechnoGecko commented 2 years ago

Oh! You're right, that's just the public getter. Nice 👍