PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 182 forks source link

Change to s_players array to make it scalable for more players #154

Closed ztsalexey closed 1 year ago

ztsalexey commented 1 year ago

Changed s_players array to mapping(uint256 => address) private s_playersMapping uint256 private s_playersCount, along with the implementation in the fulfillRandomWords. Now instead of working with arrays, contract uses mapping so chainlink VRF does not run out of gas in case there are a lot of players (running out of gas due to new address[](0) operation, now it is just changing the counter s_playersCount = 0 for fixed gas).

Modified test case not to call the array values just to keep it complete.

ztsalexey commented 1 year ago

Just realized it will not help the course video, closing the request.