Skip to content

Commit

Permalink
Add alternative format for calculateFractional
Browse files Browse the repository at this point in the history
There is no need to pass all values manually to calculateFractional,
except for testing maybe, so it was updated for convenience.
  • Loading branch information
dexX7 committed Sep 20, 2015
1 parent 354b678 commit 1437b27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/omnicore/sp.cpp
Expand Up @@ -589,6 +589,17 @@ bool mastercore::isCrowdsaleActive(uint32_t propertyId)
return false;
}

int64_t mastercore::calculateFractional(const CMPSPInfo::Entry& sp, const CMPCrowd& crowdsale)
{
return calculateFractional(sp.prop_type,
sp.early_bird,
sp.deadline,
sp.num_tokens,
sp.percentage,
crowdsale.getDatabase(),
crowdsale.getIssuerCreated());
}

// calculates and returns fundraiser bonus, issuer premine, and total tokens
// propType : divisible/indiv
// bonusPerc: bonus percentage
Expand Down Expand Up @@ -845,13 +856,7 @@ unsigned int mastercore::eraseExpiredCrowdsale(const CBlockIndex* pBlockIndex)
assert(_my_sps->getSP(crowdsale.getPropertyId(), sp));

// find missing tokens
int64_t missedTokens = calculateFractional(sp.prop_type,
sp.early_bird,
sp.deadline,
sp.num_tokens,
sp.percentage,
crowdsale.getDatabase(),
crowdsale.getIssuerCreated());
int64_t missedTokens = calculateFractional(sp, crowdsale);

// get txdata
sp.historicalData = crowdsale.getDatabase();
Expand Down
1 change: 1 addition & 0 deletions src/omnicore/sp.h
Expand Up @@ -227,6 +227,7 @@ bool isCrowdsalePurchase(const uint256& txid, const std::string& address, int64_
int64_t calculateFractional(uint16_t propType, uint8_t bonusPerc, int64_t fundraiserSecs,
int64_t numProps, uint8_t issuerPerc, const std::map<uint256, std::vector<int64_t> >& txFundraiserData,
const int64_t amountPremined);
int64_t calculateFractional(const CMPSPInfo::Entry& sp, const CMPCrowd& crowdsale);

void calculateFundraiser(bool inflateAmount, int64_t amtTransfer, uint8_t bonusPerc,
int64_t fundraiserSecs, int64_t currentSecs, int64_t numProps, uint8_t issuerPerc, int64_t totalTokens,
Expand Down

0 comments on commit 1437b27

Please sign in to comment.