Skip to content

Commit 1437b27

Browse files
committed
Add alternative format for calculateFractional
There is no need to pass all values manually to calculateFractional, except for testing maybe, so it was updated for convenience.
1 parent 354b678 commit 1437b27

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/omnicore/sp.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,17 @@ bool mastercore::isCrowdsaleActive(uint32_t propertyId)
589589
return false;
590590
}
591591

592+
int64_t mastercore::calculateFractional(const CMPSPInfo::Entry& sp, const CMPCrowd& crowdsale)
593+
{
594+
return calculateFractional(sp.prop_type,
595+
sp.early_bird,
596+
sp.deadline,
597+
sp.num_tokens,
598+
sp.percentage,
599+
crowdsale.getDatabase(),
600+
crowdsale.getIssuerCreated());
601+
}
602+
592603
// calculates and returns fundraiser bonus, issuer premine, and total tokens
593604
// propType : divisible/indiv
594605
// bonusPerc: bonus percentage
@@ -845,13 +856,7 @@ unsigned int mastercore::eraseExpiredCrowdsale(const CBlockIndex* pBlockIndex)
845856
assert(_my_sps->getSP(crowdsale.getPropertyId(), sp));
846857

847858
// find missing tokens
848-
int64_t missedTokens = calculateFractional(sp.prop_type,
849-
sp.early_bird,
850-
sp.deadline,
851-
sp.num_tokens,
852-
sp.percentage,
853-
crowdsale.getDatabase(),
854-
crowdsale.getIssuerCreated());
859+
int64_t missedTokens = calculateFractional(sp, crowdsale);
855860

856861
// get txdata
857862
sp.historicalData = crowdsale.getDatabase();

src/omnicore/sp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ bool isCrowdsalePurchase(const uint256& txid, const std::string& address, int64_
227227
int64_t calculateFractional(uint16_t propType, uint8_t bonusPerc, int64_t fundraiserSecs,
228228
int64_t numProps, uint8_t issuerPerc, const std::map<uint256, std::vector<int64_t> >& txFundraiserData,
229229
const int64_t amountPremined);
230+
int64_t calculateFractional(const CMPSPInfo::Entry& sp, const CMPCrowd& crowdsale);
230231

231232
void calculateFundraiser(bool inflateAmount, int64_t amtTransfer, uint8_t bonusPerc,
232233
int64_t fundraiserSecs, int64_t currentSecs, int64_t numProps, uint8_t issuerPerc, int64_t totalTokens,

0 commit comments

Comments
 (0)