Merge pull request #91 from colterj199/master

Moving failsafe check to doBuy so that it covers both normal and guar…
This commit is contained in:
Jarrad 2017-06-15 13:55:35 +08:00 committed by GitHub
commit b058a51590
1 changed files with 4 additions and 1 deletions

View File

@ -205,7 +205,6 @@ contract StatusContribution is Owned, TokenController {
require(tx.gasprice <= maxGasPrice); require(tx.gasprice <= maxGasPrice);
uint256 toCollect = dynamicCeiling.toCollect(totalNormalCollected); uint256 toCollect = dynamicCeiling.toCollect(totalNormalCollected);
assert(totalNormalCollected.add(toCollect) <= failSafe);
uint256 toFund; uint256 toFund;
if (msg.value <= toCollect) { if (msg.value <= toCollect) {
@ -237,6 +236,10 @@ contract StatusContribution is Owned, TokenController {
function doBuy(address _th, uint256 _toFund, bool _guaranteed) internal { function doBuy(address _th, uint256 _toFund, bool _guaranteed) internal {
require(msg.value >= _toFund); // Not needed, but double check. require(msg.value >= _toFund); // Not needed, but double check.
uint256 totalCollected = totalNormalCollected.add(totalGuaranteedCollected);
uint256 toCollect = dynamicCeiling.toCollect(totalCollected);
assert(totalCollected.add(toCollect) <= failSafe);
if (_toFund > 0) { if (_toFund > 0) {
uint256 tokensGenerated = _toFund.mul(exchangeRate); uint256 tokensGenerated = _toFund.mul(exchangeRate);
assert(SNT.generateTokens(_th, tokensGenerated)); assert(SNT.generateTokens(_th, tokensGenerated));