Closed gundas closed 7 years ago
The checkReward
does the 80% of the contract, that's why I have coded several days.
We can not calculate for everyone (1000+) his/her reward on every Schelling round. That's why we need calculate it when he/his request them.
Yes maybe we can call some delete
functions, but I don't know that its profitable? (We need call providerDB
for deleting).
You would also avoid strange situations when the reward calculation happens within the same block as the shelling round change (depending on the transaction execution order, the outcomes would be different).
This is no problem, the Ethereum protocol should do that for us. If my transaction executed after an new Schelling round, then I receive for this my reward too. When before, then I don't receive that
This is a suggestion for quite a big change.
Currently the code to calculate the rewards is extremely complex. One of the reasons for complexity is that the calculation is done 'on demand' when a user calls
getReward
function. If the rewards were calculated when the new shelling round occurs, there would be no reason to store all the historical data (that data is mostly needed to calculate the historical rewards). The new shelling round function would get more expensive in terms of gas, but the calculations would get less complex and there would be less data to store within the provider contract. You would also avoid strange situations when the reward calculation happens within the same block as the shelling round change (depending on the transaction execution order, the outcomes would be different).