Open adamdossa opened 6 years ago
Thanks! Took care of point one. Do you know of a code or contract example of your linked list approach that I could refer to?
Someone also suggested that because the contract now uses a nomination period for potential winners, to just keep state of who the current best nominated guess is instead of keeping state of all nominated guesses.
For an ordered linked list implementation, you can take a look at:
https://github.com/melonproject/smart-contracts/blob/develop/src/system/OperatorStaking.sol
If you google it you'll probably find other simpler implementations.
Having users need to nominate their prior guesses, and only keeping the winning nominated guess would be another workable approach as you say.
Couple of issues:
payable
which it shouldn't be and could lose ETH.One approach here is to keep guesses in an ordered linked list. You can check the winner by having a function that takes a 'seed' to start searching in the linked list which means it can be executed in constant time (calculating the seed off-chain).