Description
F-OBrien 24 minutes ago
Optimization Suggestion?
I could be wrong here but is there a logic to using tokensMinted instead of totalTokensSold? Are they not essentially the same thing? totalTokensSold only seems to be update after the STO is finaliszed. Instead there currently is an additional function that regularly calculates tokensMinted. If totalTokensSold was update as tokens were minted instead it would save the need for getTokensMinted(), which is called multiple times and recalculates each time. It could simply be replaced with totalTokensSold. This would then allow you to remove getTokensMinted() and also remove the getTokensSold() function as totalTokensSold already has a public getter.
So by adding totalTokensSold = totalTokensSold.add(tierPurchasedTokens) after tierData.mintedTotal = tierData.mintedTotal.add(tierPurchasedTokens) in the _calculateTier function I think it allows this optimization.
The finalize() function could then also be tidied up a bit.